Jump to content
  • Advertisement
Sign in to follow this  
ToastFlambe

Very simple inheritance problem

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

Ok, I've got a class, Quad, that has a few simple functions such as Rotate, SetWorldPosition, SetDimensions, and an array that holds four Vector2's. I want to use this as a base class (preferably an ADT) to two other classes: RenderQuad and BoundingQuad. I know a couple ways I could do this. a) I could make Quad an ADT, make all the functions pure virtual, provide an implementation for them, and then have the derived classes' functions call the ADT's functions. b) I could just use normal inheritence and just not create a Quad object Right now, b is very tempting because its simple, but I know its not really "proper C++" :P. Any suggestions as to which one or is there an option I missed? Edit: In fact, it almost feels like overkill to do (a) because there really isn't that much more functionality I need to add to the derived classes. [Edited by - Alt F4 on October 9, 2005 11:24:43 PM]

Share this post


Link to post
Share on other sites
Advertisement
Just so it's clear to me, you'd like to make Quad an ADT and expose Rotate, SetWorldPosition and SetDimensions as the interface? Or are those the common inheritence functions and you want to abstract a different set of interfaces?

Share this post


Link to post
Share on other sites
If you want to put most of your implementation in Quad and just not allow its instantiation, you can either -

1. Have at least one pure virtual function in Quad;
2. Hide the constructor(s) of Quad in the protected area.

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.

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!