My compiler gives me a warning for having the same header file in 2 source files. I don't know how else I would make my application.Here is my shorten code:
mapmaker.h
1>winManager.obj : error LNK2005: "public: __thiscall winManager::winManager(void)" (??0winManager@@QAE@XZ) already defined in main.obj
1>winManager.obj : error LNK2005: "public: __thiscall map_maker::map_maker(void)" (??0map_maker@@QAE@XZ) already defined in main.obj
1>winManager.obj : error LNK2005: "public: __thiscall map::map(void)" (??0map@@QAE@XZ) already defined in main.obj
1>winManager.obj : error LNK2005: "public: __thiscall object::object(void)" (??0object@@QAE@XZ) already defined in main.obj
Map Maker.exe : fatal error LNK1169: one or more multiply defined symbols found
Map and Object are defined in mapmaker.h along with map_maker.
Your problem is because you are putting non-inline function bodies in your headers. Take a look at Winmanager.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#ifndef _WINMANAGER
#define _WINMANAGER
#include "resource.h"
#include "include.h"
#include "mapmaker.h"
class winManager
{
map_maker* process;
winManager();
};
winManager::winManager() // <- defined in the header
{
process=new map_maker;
}
extern winManager window;
#endif
This will create duplicate function bodies which will confuse the linker. Solutions are:
1) Implicitly inline it (put the function body in the actual class
or
2) Explictly inline it (put the 'inline' keyword at the start of line 12)
or
3) Move the function body to a cpp file.
You also have the same problem with your map_maker, map, and object constructors.
it must be before windows.h, or you're wasting your time defining it. It's purpose is to tell windows.h to only include the most commonly used headers, to speed up compile time.