I wish to introduce some additional (and general) functional to an existing (and foreign) freepascal's unit.
With C++'s multiple inheritance quality it is easy to implement: ---
#include <stdio.h>
#include <list>
using namespace std;
class TObj {
protected:
int fff;
};
class TObj2: TObj {
protected:
int fff2;
};
class TIntf {
public:
virtual void ppp() = 0;
};
class TObji: public TIntf,TObj {
public:
virtual void ppp();
};
class TObj2i: public TObji,TObj2 {
public:
virtual void ppp();
};void TObji::ppp()
{
printf("111 %p\n",this);
fff = 111;}
void TObj2i::ppp()
{
printf("222 %p\n",this);
fff2 = 222;
TObji::ppp(); // like "inherited" in pascal
}
typedef list<TIntf*> myList;int main(void)
{
myList l;
l.push_back(new TObji);
l.push_back(new TObj2i);
for (myList::iterator i = l.begin(); i != l.end(); ++i)
(*i)->ppp(); // general interface used}
---
TObj,TObj2 - the basic classes from foreign module TObji,TObj2i - my additional functional implementation
But i can't invent nothing like that (except the some procedural hack with pointers substitution), in object pascal, with him interfaces! Can somebody direct me to some object-style variant, maybe objfpc relieve here (now i use delphi mode) ?
