Hi all,
I declared a vector of pointers in a header file named "bug.h"
#ifndef BUG_H
#define BUG_H
#include <vector>
#include "board.h"
#include "prey.h"
class Bug: public Prey{
public:
Bug(Board& boa);
Bug(int x,int y,Board& boa);
void breed(Board& boa);
int getx();
int gety();
};
typedef Bug* Bugpt;
std::vector <Bugpt> Bugarr(6);
void in_Bugarr(Board& boa);
#endif
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
I tried to use extern too
extern vector <Bugpt> Bugarr(6); //in "bug.cpp"
But this error appeared
error C2374: 'Bugarr' : redefinition; multiple initialization
Thx for ur help in advance.