Static members.....creating problem
Following is the code I had written for a class list. It contains a static int Pos, which I wanted to initialise.
Code:
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;
However, upon compiling the program I get the following linker error
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.