A
Andreas Lagemann
Hi,
after browsing FAQ and archive for a while I decided that the following
is a legal question.
Consider this:
Class Base
{
public:
Base() {}
Base(A* a, B* b);
virtual A* foo(P* p, S& s); // using myA and myB
protected:
A* myA;
B* myB;
};
class Der : public Base
{
public:
Der(O* o) : Base(), myO(o) {}
A* foo(P* p; S& s); // not using myA and myB
private:
O* myO;
};
class Bogus
{
public:
Bogus(Base* b) : myBase(b) {}
void bar()
{
...
myBase->foo(p,s);
...
}
private:
Base* myBase;
};
int main(/*args*/)
{
...
Der der(someO);
Bogus* bogus = new Bogus(der);
...
bogus->bar();
...
};
Executing this results in Base::foo being called instead of Der::foo
(what I would expect) ....
What am I doing wrong ?
Is that because cstr of Der does not initialize any mebers of Base ?
How could I possibly avoid that or get the behaviour I need ?
Pleas help!!!
Regards,
Andreas Lagemann
after browsing FAQ and archive for a while I decided that the following
is a legal question.
Consider this:
Class Base
{
public:
Base() {}
Base(A* a, B* b);
virtual A* foo(P* p, S& s); // using myA and myB
protected:
A* myA;
B* myB;
};
class Der : public Base
{
public:
Der(O* o) : Base(), myO(o) {}
A* foo(P* p; S& s); // not using myA and myB
private:
O* myO;
};
class Bogus
{
public:
Bogus(Base* b) : myBase(b) {}
void bar()
{
...
myBase->foo(p,s);
...
}
private:
Base* myBase;
};
int main(/*args*/)
{
...
Der der(someO);
Bogus* bogus = new Bogus(der);
...
bogus->bar();
...
};
Executing this results in Base::foo being called instead of Der::foo
(what I would expect) ....
What am I doing wrong ?
Is that because cstr of Der does not initialize any mebers of Base ?
How could I possibly avoid that or get the behaviour I need ?
Pleas help!!!
Regards,
Andreas Lagemann