Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设类Data有一个本地类模板Element<i>,下面的代码有编译错误。代码看似简单,但有什么问题?
Data
Element<i>
template<unsigned i, class Data> class A { public: typedef typename Data::Element<i> ElementTy; // compilation error: token error };
你需要template关键字:
template
typedef typename Data::template Element<i> ElementTy;
这告诉编译器后面的名称是一个模板。