我得到以下错误。我无法理解它发生在哪里?哪里出错了。我正在开发一些代码,
abc.h
#include<vector>
vector<string> vect;
vector<string>::iterator ab;
def.c
#include "abc.h"
vect.push_back("a");
vect.push_back("b");
for(ab = vect.begin(); ab != vect.end(); ab++)
{
if(*ab == "b")
{
FIle *file->fun();
}
abc.c
#include "abc.h"
File::file()
{
vect.insert(1, "Something");
}
我收到一个错误
"class std::_Vector_iterator<class std::_Vector_val<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > testCase" (?testCase@@3V?$_Vector_iterator@V?$_Vector_val@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@std@@A) already defined in abc.obj
1>GTestThread.obj : error LNK2005: "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > vect" (?vect@@3V?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@A) already defined in abc.obj
1>D:/ fatal error LNK1169: one or more multiply defined symbols found