2012-10-03 2 views
0

저는 클래스 템플릿을 처음 사용하는데 문제가 있습니다. 나는 선언하지 않는 함수를 가진다 (즉, int, double 등). 그러나이 함수에서 선언하는 것은 이치에 맞지 않습니다. 따라서 나는 오류가 발생합니다. 도와 주셔서 감사합니다.arg 목록 (선언되지 않은 식별자)이없는 클래스 템플릿 사용

내가 가지고있는 다음과 같은 기능 :

오류 1 오류 C2065 : 'ItemType은': 선언되지 않은 식별자 오류이 오류 C2955 : 'QueType'의 사용이 다음과 같은 오류를 반환

bool QueType<ItemType>::IsEmpty() const 
// Returns true if there are no elements on the queue and false otherwise. 
{ 
    return (front == NULL); 
} 

클래스 템플릿 템플릿 인수 목록이 필요합니다
오류 3 오류 C2509 : 'IsEmpty': 'QueType'에 멤버 함수가 선언되지 않았습니다.

답변

2

내 생각은

template <typename ItemType> 
bool QueType<ItemType>::IsEmpty() const 
// Returns true if there are no elements on the queue and false otherwise. 
{ 
    return (front == NULL); 
} 
+0

하 하. 한 줄의 코드가 없어서 많은 시간을 낭비했습니다. 감사합니다. – Zzz

2

함수 선언 앞에 template <typename ItemType>을 추가하십시오.

관련 문제