上课Data
有一个本地类模板 Element<i>
,下面的代码有编译错误。代码看似简单,但有什么问题呢?
template<unsigned i, class Data>
class A
{
public:
typedef typename Data::Element<i> ElementTy; // compilation error: token error
};
最佳答案
您需要 template
关键字:
typedef typename Data::template Element<i> ElementTy;
这告诉编译器后面的名称是一个模板。
关于c++ - 在类模板中定义一种本地类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17607042/