469,128 Members | 1,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,128 developers. It's quick & easy.

calling virtual function results in calling function of base class ...

On Andreas Lagemann <an**************@freenet.de> wrote:

Class Base
Base() {}

Base(A* a, B* b);

virtual A* foo(P* p, S& s); // using myA and myB
Make sure you have a virtual destructor, private copy constructor and
private assignment operator.
Executing this results in Base::foo being called instead of Der::foo
Did you make a typo or something. It will call Der::foo if your foo
signature is exact the same in Der.
Are you sure you use pointers when you are passing the Der object as a
Base object? To make sure use private copy constructor and private
assignment operator so you will not lose the Der object info when
copying the object.

(what I would expect) ....
What am I doing wrong ?
Is that because cstr of Der does not initialize any mebers of Base ?

Cheers Tim
Jul 22 '05 #1
0 951

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by mshetty | last post: by
12 posts views Thread by Peter Cranz | last post: by
3 posts views Thread by Klaas Vantournhout | last post: by
7 posts views Thread by sam_cit | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.