64,646
社区成员
发帖
与我相关
我的任务
分享
class TextQuery
{
public:
typedef vector<string>::size_type line_no;//修改1:行号为vector<>::size_type 类型,这里可以用typedef
void read_file(ifstream &is)
{
store_file(is); //修改2:添加了两个private函数
build_map();
}
set<line_no> run_query(string &s) const; //修改3:返回值为set对象的const引用?
string text_line(line_no) const; //修改4:定义常成员函数const放在后面
private:
//修改
//实现read_file
void store_file(ifstream&); //store input file
void build_map(); //
vector<string> lines_of_text;
//set<line>;
//map word to set of lines on which it occurs
map(string, set<line_no>) word_map;
}
void store_file(ifstream &is)::TextQuery
{
string word;
//类的私有函数怎么访问私有变量?
while(is>>word)
}
直接访问有问题吗?