谁帮我看看啊编译出错为何?怎么解决啊
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <stddef.h>
#include <ctype.h>
using namespace std;
typedef pair <short,short> location;
typedef vector <location> loc;
class Query
{
public:
virtual ~Query(){ delete _solution; }
Query():_solution(0){};
Query(const vector <location> &loc):_solution(0),_loc(loc){};
virtual void eval()=0;
void display();
set <short> *solution(){return _solution?_solution:_solution=_vec2set(&_loc);}
vector <location> *locations(){return &_loc;}
static vector <string> *text_file(){return _text_file;}
protected:
set <short> * _vec2set(const vector <location> *);
static vector <string> *_text_file;
set <short> *_solution ;
vector <location> _loc;
};
void
Query::
display()
{
if(!_solution-> size())
{
cout < < "\n\tSorry, "
< < "no matching lines were found in text.\n "
< <endl;
}
set <short> ::const_iterator it=_solution-> begin(),end_it=_solution-> end();
for(;it!=end_it;++it)
{
int line =*it;
cout < < "( " < <line+1 < < ") "
< <(*_text_file)[line] < < '\n ';
}
cout < <endl;
}
int main()
{
return 0;
}
Linking...
Query.obj : error LNK2001: unresolved external symbol "protected: static 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_tra
its <char> ,class std::allocator <char> > > > * Query::_text_file " (?_text_file@Query@@1PAV?$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)
Debug/Query.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Query.exe - 2 error(s), 0 warning(s)
是什么问题啊?哪位有空复制过去编下啊
[解决办法]
static vector <string> *Query::_text_file=NULL;
在代码中加上