아래에 나와있는 것처럼 중첩 클래스의 정규화 된 이름을 사용하려고 시도했지만 컴파일러가 숨막히는 것입니다!gcc가 중첩 클래스에서 오류를 반환합니다.
template <class T> class Apple {
//constructors, members, whatevers, etc...
public:
class Banana {
public:
Banana() {
//etc...
}
//other constructors, members, etc...
};
};
template <class K> class Carrot{
public:
//etc...
void problemFunction()
{
Apple<int>::Banana freshBanana = someVar.returnsABanana(); //line 85
giveMonkey(freshBanana); //line 86
}
};
내 문제는 컴파일러는 말한다되어
Carrot.h:85: error: expected ';' before 'freshBanana'
Carrot.h:86: error: 'freshBanana' was not declared in this scope
나는 완전한 이름을 사용하는이 중첩 된 클래스에 액세스 저를 허용 생각했다? 그것은 아마 얼굴에 나를 때려 눕힐 것이다. 그러나 내가 지구상에서 무엇을 여기에서 보지 않고 있냐??
이전 버전의 gcc로 중첩 된 클래스에서 컴파일 문제가 발생했습니다 (gcc-3.4 사용). gcc-4.x에는 이러한 문제가 없으며이 코드는 작은 재 작업 후 잘 컴파일됩니다. 슬프게도, 아니요, –