i am getting a link error in my program which states that some variable which i declared in my header file is already defined in the object file.
The error is like this:
error LNK2005: "struct list * first" (?first@@3PAUmylist@@A) already defined in list.obj
error LNK2005: "struct list * last" (?first@@3PAUmylist@@A) already defined in list.obj
error LNK2005: "struct list * current" (?first@@3PAUmylist@@A) already defined in list.obj
this is the declaration i am using in myheader file:
Expand|Select|Wrap|Line Numbers
- #ifndef LIST_H
- #define LIST_H
- # include<iostream>
- # include<list>
- # include<vector>
- struct list
- {
- int number;
- list *previous;
- list *next;
- };
- vector <list *> listpointer; // Vector having the pointer to the elements of the list.
- list *first; // is the head of the list.
- list *last; // store the last position of the list.
- list *current; // for maintiaining the current position
- void add_first();
- #endif