Sign in to follow this  
Mizipzor

Class inheritance [solved]

Recommended Posts

Mizipzor    247
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this