template<class T> class mStack { private: vector<T> a; vector<T>::iterator top; public: void push(T); T pop(); mStack(); void printStack(); };
The code with above class is not getting compiled… why? What is the problem? The compiler says ‘expected ; above top’.
You need a typename:
This reassures the compiler thar
vector<T>really is a type. For a discussion of this and other template gotchas, see the C++ FAQ.