c2955 Error - Use of Class template reuires argument list

≯℡__Kan透↙ 提交于 2019-12-02 05:55:41

You have defined Vector<T> as a member of Stack already, it's not necessary to inherit from Vector

Update

template <class T>
class Stack : public Vector{       
   //...
};

To:

template <class T>
class Stack {
   Vector<T> stack;   
   //...
};

Or if you want to inherit from a template class, you need to provide template parameter

template <class T>
class Stack : public Vector<T>{
//                         ^^^

Note:

You miss a few semicolons in Stack function definition and a bug in Stack::push_back as well, I may suggest update to below:

template <class T>
class Stack 
{
private:
    Vector<T> stack;
public:
    Stack(){};
    void push(T const& x) {stack.push_back(x);}
    void pop(){stack.pop_back();}
    bool empty(){return stack.empty();}

};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!