在UIHandling.h中:
enum eType{...};
class UIHandling : public exception
{
...
UIHandling(eType);
template <class T>
UIHandling(eType, T);
...
}
在另一个文件CompaniesMap
中我使用不同的enums
和不同类型的第二个变量(double
,unsigned int
,eType
多次调用第二个构造函数,等...)
我收到以下错误:
1>CompaniesMap.obj : error LNK2019: unresolved external symbol "public: __thiscall UIHandling::UIHandling<double>(enum eType,double)" (??$?0N@UIHandling@@QAE@W4eType@@N@Z) referenced in function __catch$?addCompany@CompaniesMap@@UAEXXZ$2
1>CompaniesMap.obj : error LNK2019: unresolved external symbol "public: __thiscall UIHandling::UIHandling<__int64>(enum eType,__int64)" (??$?0_J@UIHandling@@QAE@W4eType@@_J@Z) referenced in function __catch$?addCompany@CompaniesMap@@UAEXXZ$4
1>CompaniesMap.obj : error LNK2019: unresolved external symbol "public: __thiscall UIHandling::UIHandling<unsigned int>(enum eType,unsigned int)" (??$?0I@UIHandling@@QAE@W4eType@@I@Z) referenced in function __catch$?changeHoldingAmount@CompaniesMap@@UAEXXZ$0
1>CompaniesMap.obj : error LNK2019: unresolved external symbol "public: __thiscall UIHandling::UIHandling<class Date>(enum eType,class Date)" (??$?0VDate@@@UIHandling@@QAE@W4eType@@VDate@@@Z) referenced in function "public: virtual void __thiscall CompaniesMap::postponeExpiryDate(void)" (?postponeExpiryDate@CompaniesMap@@UAEXXZ)
1>D:\Asaf\C\VS\hw5\HW5\Debug\HW5.exe : fatal error LNK1120: 5 unresolved externals
我是否需要将类本身定义为模板?如果是这样的话?如果没有,为什么会出现错误?