-1
在此设置:如何从模板派生类中的模板化基类调用成员?
template<int N>
struct Base {
void foo();
};
class Derived : Base<1> {
static void bar(Derived *d) {
//No syntax errors here
d->Base<1>::foo();
}
};
,一切工作正常。然而,这个例子:
template<class E>
struct Base {
void foo();
};
template<class E>
class Derived : Base<E> {
static void bar(Derived<E> *d) {
//syntax errors here
d->Base<E>::foo();
}
};
我得到:
error: expected primary-expression before '>' token
error: '::foo' has not been declared
有什么区别?为什么第二个会导致语法错误?
您使用的编译器是什么? – 2013-03-04 10:41:48
织补,错字。这个问题是垃圾。 – Eric 2013-03-04 10:47:32