I am having a problem linking that I can't seem to resolve....
There are 3 source files:
main.cpp, map.cpp, terrain.cpp
There are 3 header files:
map.h, terrain.h, vectordtp.h
terrain.h looks like:
Code:
#ifndef __TERRAIN_DTP_H
#define __TERRAIN_DTP_H
//Includes
#include "SDL.h"
...some constants defined....
class TERRAIN_MANAGER_DTP
{
friend class TERRAIN_DTP;
...class declaration...
} DefaultTileManager;
class TERRAIN_DTP
{
....class declaration
};
#endif
terrain.cpp includes terrain.h and defines all functions in from the classes.
map.h looks like such:
Code:
#ifndef __MAP_DTP_H
#define __MAP_DTP_H
#include "terrain.h"
#include "vectordtp.h"
/*********************
MAP_DTP class
*********************/
class MAP_DTP
{
...class declaration...
};
#endif
map.cpp includes map.h and defines all functions from the class.
vectordtp.h is a simple header file that defines my own vector and matrix classes....with both the declaration and definitions in the same file (the function definitions are encapsulated inside the class declaration).
main.cpp looks like such:
Code:
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif
//Includes
#include "SDL.h"
//#include "terrain.h"
//#include "map.h"
//Color masks
bool MessageLoop ( SDL_Event &event );
int main(int argc, char **argv)
{
...code....
}
This is the error I am receiving:
terrain.obj : error LNK2005: "class TERRAIN_MANAGER_DTP DefaultTileManager" (?DefaultTileManager@@3VTERRAIN_MANAGER_DTP@@A) already defined in map.obj
I have tried moving around some include statements and such...but I can't seem to resolve this linking problem. Any ideas?