I have a Bullet class that has a function draw(). It want to pass in a static member(object of a SDL_surface class) to this function but not sure how to do it correctly.
my classes :
class AllyBullet: public Bullet
{
public:
static SDL_Surface *sprite;
};
class EnemyBullet: public Bullet
{
public:
static SDL_Surface *sprite;
};
void Bullet::Draw(SDL_Surface *screen)
{
DrawSprite(screen,sprite,posX,posY);
}
Bullet does not have a sprite member. How can i write it so that it will know its for the classes that inherit it?
You can make the sprite virtual. Something like this: