2014-01-30 2 views
0

내가 다음과 같은 오류가 발생했습니다LNK2019 오류가

"대해서는 2 9 오류 LNK2019 : Verweis 안녕히 nicht의 aufgelöstes externes 기호", "대중 : BOOL __cdecl gameClass :: 대해 getAttribute (클래스 표준 : : basic_string, 클래스 std :: allocator>) "("std :: allocator>) "($ getAttribute @ _N @ gameClass @@ QEAA_NV? $ basic_string @ DU? char_traits @ D @ std @@ V? $ allocator @D @ 2 @ std @@@ Z)" Funktion에서 "주요"C :. \ 사용자 \ Weexe 프로젝트 \ 엔진 \ 엔진 \의 main.obj 엔진 "

내 코드 class.h \ 비주얼 스튜디오 2010 \ 문서 \

template <typename T> T getAttribute(std::string attribute); 

class.cpp

template <typename T> 
T gameClass::getAttribute(std::string attribute) 
{ 
std::map<std::string,int> matchAttribute; 

matchAttribute["windowTitle"]=1; 
matchAttribute["windowSizeX"]=2; 
matchAttribute["windowSizeY"]=3; 
matchAttribute["isMenue"]=4; 

switch(matchAttribute[attribute]) 
{ 
case 1: 
    return this->windowTitle; 
    break; 
case 2: 
    return this->windowSizeX; 
    break; 
case 3: 
    return this->windowSizeY; 
    break; 
case 4: 
    return this->isMenue; 
    break; 
} 
} 

어느 하나가 어떻게 오류를 수정하는 idear가? 나는 그것의 구문 오류 또는 smth 그런 생각 :/

+0

또한 누군가가 장난을 치고 OS 언어를 독일어로 변경 한 것 같습니다. –

+0

장난이 아니며 나는 독일인입니다. – Weexe

+0

오, 죄송합니다. –

답변

0

템플릿은 헤더 파일 (.h, .hpp, .inl) e.t.c에서만 구현할 수 있습니다. 이것은 새로운 헤더 파일을 만들기 위해 클래스 .cpp의 코드가 class.h의 코드와 '결합'되어야 함을 의미합니다.

+0

오, 알아두면 좋구나! 그래서 헤더 파일에 내 코드가 필요합니다. 나는 그것을 시도 할 것이다. – Weexe

관련 문제