Jump to content
  • Advertisement

Archived

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

jonbell

Inhertiance

This topic is 5777 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 have a method in my base class called SetRotation. In my derived class i want to extend this method and do a little more. How do i call the SetRotation method in my base class from my SetRotation method in my derived class (in C++). Cheers

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by siaspete
This is called the template pattern.

What is?

Template looks like this:


  
class Base
{
public:
void foo()
{
doSomething();
doSomethingElse();
}
protected:
virtual void doSomething() = 0;
virtual void doSomethingElse() = 0;
}


foo() then takes on transactional characteristics, and you override the protected members in derived classes to customise the behaviour of the transaction. You can also provide a default implementation in Base, if that''s what you want.

Share this post


Link to post
Share on other sites
Indeed. Don't know what you mean by the template pattern, but I think you're confusing it with scope resolution. Hence the use of the scope resolution operator ( :: ).

But, you're right, CBaseClass::SetRotation() is the way to go.



[edited by - Bas Paap on December 1, 2002 11:02:40 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!