输入的关键词即为一个字符数组(字符串),本文将以"abcdef"这个字符串为例。要想完成对片段的查询
void findByName(InterntBar& bar) { string str; cout << "请输入您想要搜索的姓名:"; cin >> str; vector<Information> list = bar.findByName(str); for (auto& c : list) { cout << c.info() << endl; } }
void findByGroup(InterntBar& bar) { string str; cout << "请输入您想要展示的分组:"; cin >> str; vector<Information> list = bar.findByGroup(str); for (auto& c : list) { cout << c.info() << endl; } }
string Information::info() { ostringstream oss; oss << "||名字:" << name<< "||会员类别:" << group << endl; return oss.str(); }