Hello,
I'm working on a game, and for this game, I created a class. There is one object of this class for each player in the game:
class PlayerClass
{
public:
PlayerClass(Nationality); // Constructor
~PlayerClass(); // Destructor
sf::Sprite PlayerFeet;
sf::Sprite Arms;
sf::Sprite Body;
sf::Sprite Head;
int HitPoints;
GameClass CurrentClass;
};
PlayerClass::PlayerClass(Nationality natl)
{
PlayerFeet.SetImage(iFeet);
HitPoints = 100;
CurrentClass = SCOUT_SNIPER;
if(natl == UK)
{
Arms.SetImage(iUK_Arms);
Body.SetImage(iUK_Body);
Head.SetImage(iUK_Head);
}
else
{
Arms.SetImage(iNZ_Arms);
Body.SetImage(iNZ_Body);
Head.SetImage(iNZ_Head);
}
}
PlayerClass::~PlayerClass()
{
}
That is in the Classes.cpp file. If you can't tell, I'm using SFML, hence the sf:: Sprite's (added a space so it wouldn't make a :S ). These are the enumerations I have, in the Main.h header file:
enum Nationality { US, UK, RU, NZ, JP };
enum GameClass { SUPPORT, MEDIC, ENGINEER, MARKSMAN, OFFICER, SCOUT_SNIPER };
In the same project, I have the Main.cpp file:
PlayerClass PlayerA(UK);
(I have "extern PlayerClass PlayerA" in the Main.h file)
Now, when I compile this, it gives me an error, pointing to the line PlayerA is declared in Main.cpp:
"error: variable `PlayerClass PlayerA' has initializer but incomplete type"
"error: storage size of `PlayerA' isn't known"
What did I do to receive this error?