[VC6]std::vector派生类无法调用std::vector的解决方法 template<class _Ty, class _A = std::allocator<_Ty> > class CTestVector : public std::vector<_Ty,_A > { public: void clear() { std::vector<_Ty,_A >::clear(); } };
调用代码
CTestVector<int> vv; vv.clear();
出差提示:
'std::vector<int,class std::allocator<int> >::clear' : illegal call of non-static member function
解决方法
template<class _Ty, class _A = std::allocator<_Ty> > class CTestVector : public std::vector<_Ty,_A > { typedef std::vector<_Ty,_A > PARENT;
public:
void clear() { PARENT::clear(); } };