Jump to content
  • Advertisement
Sign in to follow this  
Thomo

Virtual methods

This topic is 4331 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A base class, A has a virtual function, virtual func(); Class B derives from A and B overrides A with it's own func(). Class C derives from class B. How do I tell class C to use the func() in A and not that in B.

Share this post


Link to post
Share on other sites
Advertisement
and you would put this code inside another override in class C.

C::func()
{
A::func();
}

of course this is a fairly good sign that something in your design is not quite right, because the idea of C deriving from B indicates C is more like B than A. Of course this is not always true. And definately not true if you are doing something else in addition to A::func() in C. But how does class C know it doesn't want what is in B's version ... and how will you know 6 months from now when you change B?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!