以下是代码示例:
template <class T>
class SomeClass{
typedef boost::shared_ptr<T> sPtr;
typedef std::vector<sPtr> c;
typedef c::iterator cIt; // here is the problem
};
错误信息如下:
main.cpp:23: error: type ‘std::vector<boost::shared_ptr<X>, std::allocator<boost::shared_ptr<X> > >’ is not derived from type ‘SomeClass<T>’
main.cpp:23: error: expected ‘;’ before ‘cIt’
如何在类中使用typedef来模板化参数?
编辑:
我已经弄清楚了,对于g++编译器必须这样写:
typedef typename c::iterator cIt; // here is the problem
请关闭它。