I have a class called UIHandling
inside a header file called UIHandling.h
.
At the top of the class I made sure to use:
#ifndef _UIH_
#define _UIH_
And of course ended the file with #endif
This header file consists all the implementations of the constructors. I've include this class in many files in my program but for some reason, I get the following compiler error:
1>CompaniesMap.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(enum eType)" (??0UIHandling@@QAE@W4eType@@@Z) already defined in Bond.obj
1>CompaniesMap.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(void)" (??0UIHandling@@QAE@XZ) already defined in Bond.obj
1>Company.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(enum eType)" (??0UIHandling@@QAE@W4eType@@@Z) already defined in Bond.obj
1>Company.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(void)" (??0UIHandling@@QAE@XZ) already defined in Bond.obj
1>Date.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(enum eType)" (??0UIHandling@@QAE@W4eType@@@Z) already defined in Bond.obj
1>Date.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(void)" (??0UIHandling@@QAE@XZ) already defined in Bond.obj
1>GovStock.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(enum eType)" (??0UIHandling@@QAE@W4eType@@@Z) already defined in Bond.obj
1>GovStock.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(void)" (??0UIHandling@@QAE@XZ) already defined in Bond.obj
1>main.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(enum eType)" (??0UIHandling@@QAE@W4eType@@@Z) already defined in Bond.obj
1>main.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(void)" (??0UIHandling@@QAE@XZ) already defined in Bond.obj
1>Stock.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(enum eType)" (??0UIHandling@@QAE@W4eType@@@Z) already defined in Bond.obj
1>Stock.obj : error LNK2005: "public: __thiscall UIHandling::UIHandling(void)" (??0UIHandling@@QAE@XZ) already defined in Bond.obj
1>D:\Asaf\C\VS\hw5\HW5\Debug\HW5.exe : fatal error LNK1169: one or more multiply defined symbols found
So I went to Bond.h
and Bond.cpp
to see if there's anything strange (Like an implementation of UIHandling::UIHandling()
or something like that) and there isn't.
I saw in another question that this error shows when you violate the ODR, but I didn't. In another similar question the answer was that this has something to do with including the same file over and over causing many different implementations of the constructor, but that is avoided using the #ifndef _UIH
command.
It may have something to do with how I declare and define my constructors:
In UIHandling.h
:
class UIHandling : public exception
{
public:
UIHandling(); // Default C'tor - error unknown
UIHandling(eType); // C'tor with error type
template <class T>
UIHandling(eType, T); // C'tor with error type and relevant number
...
}
...
UIHandling::UIHandling()
{
...
}
UIHandling::UIHandling(eType e)
{
...
}
template <class T>
UIHandling::UIHandling(eType e, T number)
{
...
}
Any help?