为什么以下不编译?
template <typename Child> struct Base
{
typename Child::Type t; // Does not compile. "No type named Type in Child"
};
struct Derived : public Base<Derived>
{
typedef int Type;
};
那怎么Base
不能访问它的子类型?我用静态函数而不是 typedef 进行了同样的尝试,效果很好。
我尝试了 GCC 4.4.2 和 clang 3.0。