[완료] 템플릿 클래스 내부 타입을 쓰고 싶습니다. (typename)
글쓴이: purewell / 작성시간: 월, 2007/04/23 - 7:07오후
#include <iostream>
using namespace std;
template<typename T>
class CTest
{
public:
typedef T type;
type& getWhat(type& t);
};
template<typename T>
CTest<T>::type&
CTest<T>::getWhat(CTest::type& t)
{
return t;
}위 코드에서 아래에 메서드 정의하는 부분에서 에러가 떨어집니다.
tmpl.cpp:14: error: `template class CTest' used without template parameters
tmpl.cpp:14: error: expected constructor, destructor, or type conversion before '&' token
tmpl.cpp:14: error: expected `;' before '&' token
템플릿 클래스 안에 정의한 타입을 외부에서 메서드 정의할 때 쓰고자할 땐 어떻게해야하나요?
Forums:


http://kldp.org/node/80754#co
http://kldp.org/node/80754#comment-382564
[예진아씨 피카사 웹앨범] 임예진 팬클럽 ♡예진아씨♡ http://cafe.daum.net/imyejin
어떤 컴파일러를
어떤 컴파일러를 사용하셨나요?
gcc 3.3에서는 다음과 같은 경고가 나오지만 컴파일은 됩니다.
컴파일러가
가타입의 static member 이름인지 type 이름인지
판단할 수 없다는 메세지입니다.
typename을 붙여서 명시하세요.
댓글 달기