Jump to content
  • Advertisement
Sign in to follow this  

Class inheritance [solved]

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

Sorry... solved it myself... the tutorial Ive already read was enough... the error I did was that I didnt include the header for the base class and accidently redefined some member variables. Sorry again... stop reading. :P ------------- I dont know if I spelled it right... maybe thats why I cant find that much info on the suibject through google. Anyways, I dont need a big fat tutorial for this, knows i theory kinda how its done. All the sprites in my game has a position and an image:
class Sprite {
   int posX;
   int posY;
   SDL_Surface* image;
However, some of the sprites represents enemies, and thus needs more parameters. Like health and strength. But the base values of a normal sprite to. This is whats called class inheritance, right? Something like this:

class Monster: public Sprite {
   int health;
   int strength;
How do you do it?

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!