hi,
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@@3PAUmy list@@A) already defined in list.obj
error LNK2005: "struct list * last" (?first@@3PAUmy list@@A) already defined in list.obj
error LNK2005: "struct list * current" (?first@@3PAUmy list@@A) already defined in list.obj
this is the declaration i am using in myheader file:
what is wrong with the declaration? how can i correct it? I have to use these variables in my cpp file.
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@@3PAUmy list@@A) already defined in list.obj
error LNK2005: "struct list * last" (?first@@3PAUmy list@@A) already defined in list.obj
error LNK2005: "struct list * current" (?first@@3PAUmy list@@A) already defined in list.obj
this is the declaration i am using in myheader file:
Code:
#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
Comment