#include <iostream>
template<class T> class X
{
typename T::id i;
public:
void f() {
i.g();
}
};
class Y
{
public:
class id
{
public:
void g() {
std::cout << "id.g()\n";
}
};
};
int main()
{
Y y;
X<Y> xy;
xy.f();
system("pause");
exit(0);
}
typename告诉编译将一个特殊的名字看成是一个类型。