谁能向我解释这段代码有什么问题以及如何修复它?这是一个更大项目的一部分,如果您需要更多信息以便给出答案,请告诉我。
我得到的错误是:
g++ -c search.cpp
search.cpp: In constructor ‘Search::Search()’:
search.cpp:26:26: error: ‘callnumber’ was not declared in this scope
make: *** [search.o] Error 1
Search::Search()
{
ifstream input;
input.open("data.txt", ios::in);
if(!input.good())
//return 1;
string callnumber;
string title;
string subject;
string author;
string description;
string publisher;
string city;
string year;
string series;
string notes;
while(! getline(input, callnumber, '|').eof())
{
getline(input, title, '|');
getline(input, subject, '|');
getline(input, author, '|');
getline(input, description, '|');
getline(input, publisher, '|');
getline(input, city, '|');
getline(input, year, '|');
getline(input, series, '|');
getline(input, notes, '|');
Book *book = new Book(callnumber, title, subject, author, description, publisher, city, year, series, notes);
Add(book);
}
input.close();
}