Solved

# stack class using a templace vector class overloading [] problem

Posted on 2014-09-28

I have built a vector template class and I am now building a stack class that uses the vector class.

When I overload the [] operator I am getting a cannot convert int to vector <T> c2440

definiton of {} are

Vector<T> & operator[](int index);

const Vector<T> & operator[](int index) const;

func is

template<typename T>Vector<T> & Vector<T>::operator[](int index) // Returns an object at location index without bounds checking

{

return vec_array[index];

}

template<typename T>const Vector<T> & Vector<T>::operator[](int index) const // Returns an object at location index without bounds checking

{

return vec_array[index];

}

Stack is

template <class T>

class stack: Vector <T>

{

private:

Vector<T> stack_array;

instantiated using

stack<int> Stack1;