Consider the following decleration
template<class T, int N>
class Stack
{
public:
Stack() : T[N]{} {};
class iterator;
iterator insert(iterator it, const T &v);
private:
T[N];
};
template<class T, int N>
class Stack<T,N>::iterator
{
...
};
I want to implement Stack::insert
outside the class, so I tried the following
template<class T, int N>
Stack::iterator Stack<T, N>::insert(Stack::iterator p, const T &v)
{
...
}
Now I get the following error
'Stack' is not a class, namespace, or enumeration
I tried to change to the following
template<class T, int N>
Stack<T, N>::iterator Stack<T, N>::insert(Stack::iterator p, const T &v)
{
...
}
and now the error changed to
Missing 'typename' prior to dependent type name 'Stack<T, N>::iterator'
I don't understand why I get this error and how to fix it, hope that someone can help