mardi 10 mars 2015

Initialisation of my static data member to 0 in CPP file before two constructors


Vote count:

0




Can I do this??? it tells me unresolved external symbol WTH!


I really need to initialise the value of GameObjectCount to Zero.


Also, when I use the Default constructor to build an object,,, I cant access any of its members!!


WHY?



#include "GameOb.h"


int GameOb::GameObjectCount = 0;

GameOb::GameOb()
{
GameOb::GameObjectCount++;

GameOb::x = 0;
GameOb::y = 0;
GameOb::ObjectID = GameObjectCount;

GameOb::texturePath = std::string("Ressources/GameObjects/");

std::cout << "Object has been created with Object ID : " << GameOb::ObjectID << std::endl;
}

GameOb::GameOb(int x, int y)
{
GameOb::GameObjectCount++;

GameOb::x = x;
GameOb::y = y;
GameOb::ObjectID = GameObjectCount;

GameOb::texturePath = std::string("Ressources/GameObjects/");

std::cout << "Object has been created with Object ID : " << GameOb::ObjectID << std::endl;
}


asked 23 secs ago







Initialisation of my static data member to 0 in CPP file before two constructors

Aucun commentaire:

Enregistrer un commentaire