Skip to main content
GameDev.net gamedev.net
🔒 Locked

Inheritence question

Started by Red Ant Nov 28, 2001 at 12:48 PM 4 replies 300+ views
Original Post
Red Ant
Red Ant
Hi all, If I derive a class B from a class A, and I intend to use some of A''s methods (in exactly the same way) in B, do I have to define these methods all over again in B? I used to think that that was not necessary, but now I''m not so sure anymore. Thanks for your time. Markus
SteveC
SteveC
you only have to define methods ( and declare ) in class B if you are going to override virtual methods from class A.

If you are not going to override them, and they are NOT pure virtual, then you don''t have to.


If class A has pure virtual methods then you must override them in order to make a concrete class ( one that can be instantiated )


hope this helps
Red Ant
Red Ant
Okay, thanks, that''s what I thought. But for some reason I''m getting linker errors for exactly those methods that my class B inherited from class A. :confused:
Red Ant
Red Ant
Haha, Anonymous Poster, you da man!! I did as you told me and copied and pasted the relevant code in here. As I pasted in the last file my mistake jumped right into my face! I still had some remnants of my old code in my declaration of class B (I'm currently rewriting my old project) and there was a declaration left in there that I should have deleted. That was it! Thanks for your help, guys!

Edited by - Red Ant on November 28, 2001 3:33:52 PM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.