Hi all,
I declared a vector of pointers in a header file named (bug.h)
1 2 3
typedef Bug* Bugpt; //Bug is a defined class
vector <Bugpt> Bugarr(6);
But the following errors appear
1>Pred Pray Project.obj : error LNK2005: "class std::vector<class Bug *,class std::allocator<class Bug *> > Bugarr" (?Bugarr@@3V?$vector@PAVBug@@V?$allocator@PAVBug@@@std@@@std@@A) already defined in bug.obj
1>C:\Documents and Settings\Waleed\My Documents\Visual Studio 2010\Projects\Pred Pray Project\Debug\Pred Pray Project.exe : fatal error LNK1169: one or more multiply defined symbols found
in "bug.cpp" only or in every .cpp file i include "bug.h" i it?? i tried both ways and both generate the same error.
Only in bug.cpp , that should solve your problem.
Make sure you do not have that statement in any other file and that you do NOT #include your bug.cpp file anywhere. Only the bug.h file should be #included.