Hello could somebody please explain to me in a constructive way why my derived class wont inherit from the base class
I worked with java for a descent time and this sort of thing wasnt a hurdle for me, and then I realised it was C++ that i wanted to study. With C++ when i put
example line: class derived: public base
the complier just gives an error such as expected { token
and inheritance of the base class isnt successful.
Heres the two classes
#include <iostream>
using namespace std ;
class Player: public Sprite
{
private:
public:
Player() ;
};
/*
(INHERITABLE PARENT BASE CLASS)
This class has all attributes to be inherited by all other sprite objects of the game.
*/
#include <iostream>
using namespace std ;
#include <SDL/SDL.h>
class Sprite
{
private:
// variables
int lives ;
int health ;
int x ;
int y ;
float xv ;
float yv ;
bool is_Alive ;
bool is_Dead ;
bool is_Walking ;
bool is_Running ;
bool is_Jumping ;
bool is_Falling ;
public:
// constructor / de-constructor
Sprite(int p_lives, int p_health, int p_x, int p_y, float p_xv, float p_yv, bool p_is_Alive, bool p_is_Dead, bool p_is_Walking, bool p_is_Running, bool p_is_Jumping, bool p_is_Falling)
{
lives = p_lives ;
health = p_lives ;
x = p_x ;
y = p_y ;
xv = p_xv ;
yv = p_yv ;
is_Alive = p_is_Alive ;
is_Dead = p_is_Dead ;
is_Walking = p_is_Walking ;
is_Running = p_is_Running ;
is_Jumping = p_is_Jumping ;
is_Falling = p_is_Falling ;
}
~Sprite()
{
}
// getters and setters
void set_Lives(int p_lives)
{
lives = p_lives ;
}
int get_Lives()
{
return lives;
}
void set_Health(int p_health)
{
health = p_health ;
}
int get_Health()
{
return health ;
}
void set_X(int p_x)
{
x = p_x ;
}
int get_X()
{
return x ;
}
void set_Y(int p_y)
{
y = p_y ;
}
int get_Y()
{
return y ;
}
void set_XV(float p_xv)
{
xv = p_xv ;
}
float get_XV()
{
return xv ;
}
void set_YV(float p_yv)
{
yv = p_yv ;
}
float get_YV()
{
return yv ;
}
void set_Is_ALive(bool p_is_Alive)
{
is_Alive = p_is_Alive ;
}
bool get_Is_Alive()
{
return is_Alive ;
}
void set_Is_Dead(bool p_is_Dead)
{
is_Dead = p_is_Dead ;
}
bool get_Is_Dead()
{
return is_Dead ;
}
void set_Is_Walking(bool p_is_Walking)
{
is_Walking = p_is_Walking ;
}
bool get_Is_Walking()
{
return is_Walking ;
}
void set_Is_Running(bool p_is_Running)
{
is_Running = p_is_Running ;
}
bool get_Is_Running()
{
return is_Running ;
}
void set_Is_Jumping(bool p_is_Jumping)
{
is_Jumping = p_is_Jumping ;
}
bool get_Is_Jumping()
{
return is_Jumping ;
}
void set_Is_Falling(bool p_is_Falling)
{
is_Falling = p_is_Falling ;
}
bool get_Is_Falling()
{
return is_Falling ;
}
// functions
void clip_Sprite_Sheet(SDL_Rect clip[0])
{
}
};