이 코드의 잘못된 점은 무엇입니까? gcc 4.6.1에서 "foo가이 범위에서 선언되지 않았습니다"라는 불평을 baz()에서 나타냅니다. 템플릿 중 하나가 일반 클래스 일 수 있도록 코드를 변환하면 문제가 사라집니다.C++ 클래스 템플릿 상속 퍼즐
struct Foo {
char foo;
};
template<int N>
struct Bar : public Foo
{
Bar() { foo; }
};
template<int N>
struct Baz : public Bar<N>
{
void baz() { foo; }
};
int main() {
Baz<10> f;
return 0;
}
당신이 여기서하려고하는 것을 이해하지 못했습니다. Bar() {foo;} foo 란 무엇입니까? – badmaash
이것을 종속 이름이라고합니다. http://womble.decadent.org.uk/c++/template-faq.html#base-lookup – Suma
가능한 복제본 [이 C++ 템플릿 코드가 왜 컴파일되지 않습니까?] (http://stackoverflow.com/questions)를 참조하십시오./1364837/why-doesnt-this-c-template-code-compile) – Suma