The dummyNode declaration variable was working well until i wrote iterator class as nested, now it gives me an error invalid use of non-static data member, 'linkedList::dummyNode' c++, if i removed iterator class it works well template
class linkedList
{
private:
listNode<T> * head, *tail;
listNode<T> * dummyNode = new listNode<T>;
int sz = 0;
public:
class iterator
{
public:
iterator()
{
itrNode = head;
}
void operator ++ ()
{
try{
if(itrNode == dummyNode)
throw "Sorry this is the end of the list\n";
else
{
itrNode = itrNode->next;
}
}catch(const char * error)
{
cerr << error;
}
}
T& operator *()
{
return *(itrNode->value);
}
void operator -- ();
private:
listNode<T> * itrNode;
};
linkedList();
~linkedList();
linkedList(T value, int initial_size);
iterator begin();
};