471,594 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

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

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

Class Base
{
public:
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 ?
Typo?
Is that because cstr of Der does not initialize any mebers of Base ?


Nope
Cheers Tim
Jul 22 '05 #1
0 1014

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
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.