Possible Duplicate:
Why doesn't a derived template class have access to a base template class' identifiers?C++ 템플릿, 컴파일러 오류
번역
아
#ifndef A_H
#define A_H
template <class T>
class A
{
protected :
T a;
public:
A(): a(0) {}
};
#endif
는 BH는
는#ifndef B_H
#define B_H
template <class T>
class A;
template <class T>
class B: public A <T>
{
protected:
T b;
public:
B() : A<T>(), b(0) {}
void test() { b = 2 * a;} //a was not declared in this scope
};
#endif
오류가 발생합니다 : "는이 선언되지 않았습니다 범위". (Netbeans 6.9.1).
그러나 건설
void test() { b = 2 * this->a;}
가 올 ... 문제는 어디에 있습니까?
전달 선언 또는 파일 포함 지시문을 사용하는 것이 더 좋습니까?
B.h
template <class T>
class A;
대
#include "A.h"
읽기 http://www.comeaucomputing.com/techtalk/templates/#whythisarrow –
왜 [파생 된 템플릿 클래스가 기본 템플릿 클래스 '식별자에 액세스 할 수 없습니까?] (http : // stackoverflow. co.kr/questions/1239908/why-doesnt-a-derived-template-class-have-a-base-template-class-identi) –