この設定では:
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
違いは何ですか?2番目の原因で構文エラーが発生するのはなぜですか?