So, I\'ve tested vector and it seems to be running fine. However, I\'m trying to implement a basic Stack class built off of my Vector class. I keep running into these errors whe
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();}
};