This is really starting to annoy me, whenever I "include" my header file in any of my .cpp files then I get this error:
||=== Build: Debug in Game (compiler: GNU GCC Compiler) ===|
obj\Debug\unithandler.o||In function `ZNSs4_Rep10_M_disposeERKSaIcE':|
C:\mingw32\i686-w64-mingw32\include\c++\bits\basic_string.h|245|multiple definition of `Object::ObjectID'|
obj\Debug\main.o:C:\Games\MYGAMES\TotalWar\main.cpp|8|first defined here|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|
My header file:
#ifndef UNITHANDLER_HPP
#define UNITHANDLER_HPP
#include <map>
#include <string>
#include <fstream>
#include <SFML/Graphics.hpp>
class DataHandler
{
public:
DataHandler();
void ReadGameData();
};
class Object
{
public:
static int ObjectID;
Object();
~Object();
private:
int ID = 0;
int POS_X;
int POS_Y;
int HP;
int DMG;
std::string DMG_TYPE;
std::string TYPE;
float FUEL;
float AMMO;
float MOVES;
int STATUS = 0;
void SetProperty(std::string property_type, std::string new_value);
void SetSprite(sf::Sprite sprite);
void Draw();
void Move();
void Attack(int x, int y);
int GetMoves();
int GetHP();
};
class ObjectHandler : public Object
{
public:
static int ObjectID;
ObjectHandler();
void Add();
void Remove(int id);
private:
std::vector<Object*> ActiveObjects;
};
int Object::ObjectID = 0;
ObjectHandler Obj;
void UpdateObjects();
void DrawObjects();
#endif
Help please.
Thanks in advance...