Following is the code I had written for a class list. It contains a static int Pos, which I wanted to initialise.
However, upon compiling the program I get the following linker errorCode:class list { struct node *head, *tail; static int Pos ; public: list(); ~list(); void enqueue (const int&); int deque () ; int pop() ; struct node* find(const int) const; }; int list::Pos = 0;
Main.obj : error LNK2005: "private: static int list::Pos" (?Pos@list@@0HA) already defined in list.obj
Debug/Static1.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
Where am I redifining the static int Pos ?
Is this is the wrong way to initialise a static data member ?
Please help.