Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bslayerw

C++ and inheritence

This topic is 6053 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

I was wondering (couldn''t find it in the text I have) if C++ has a concept of the "super" pointer (like Java)? If not how would someone use a base class method in a super class (from the super class method call the base class method with the same name). Example: //---------------------------------------------- class CBaseClass { virtual void update() { //do base class updating here } } void CBaseClass::update() { //update CBaseClass } //---------------------------------------------- //then in the derived class class CDerivedClass: public CBaseClass { void update(); } void CDerivedClass::update() { //I would like to call the super classes update method //first and then continue with this method // in Java you would call super.update(); //now update the CDerivedClass } //----------------------------------------------

Share this post


Link to post
Share on other sites
Advertisement
Now, I don''t know much Java, but I think this is what you''re looking for:
  
class CBaseClass {
virtual void update() {
// Do something

}
};

class CDerivedClass : public CBaseClass {
void update() {
CBaseClass::update();
// Do more stuff

}
};

I moved the functions into the class body to save space in my post .

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!