[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();
  }
};

posted on 2023-03-22 18:06  闻缺陷则喜何志丹  阅读(32)  评论(0编辑  收藏  举报  来源