我在声明模板类型时遇到了很大的困难,如下所示。
#include <cstdlib>
#include <iostream>
using namespace std;
template <class T>
class Foo
{
typedef T Bar;
};
template <class T>
typedef typename Foo<T>::Bar Bar;
int main(int argc, char *argv[])
{
Bar bar;
Foo<int> foo;
system("PAUSE");
return EXIT_SUCCESS;
}
我收到错误
template declaration of `typedef typename Foo<T>::Bar Bar'
关于线
template <class T>
typedef typename Foo<T>::Bar Bar;
我这样做是因为我想避免通过我的代码编写类型名 Foo::Bar。
我究竟做错了什么?