64,636
社区成员
发帖
与我相关
我的任务
分享
class WordTable
{
public:
typedef std::vector<std::string> WordList; ///< A list of words (strings)
typedef std::vector<std::streampos> OccurrenceList; ///< A list of file positions of a word
private:
std::map<std::string, OccurrenceList> table;
public:
/// The constructor generates an empty WordTable
WordTable(void);
/// Add the given WordOccurrence to the table.
void addWord(WordOccurrence word);
/// Add the given WordOccurrence to the table.
void WordTable::addWord(WordOccurrence word)
{
WordList::push_back(word.word);//这里提示错误
//OccurrenceList::push_back(word.position);
table.insert( pair<std::string, OccurrenceList>(WordList, OccurrenceList );
map<std::string, OccurrenceList>::iterator iter;
for (iter = table.begin(); iter != table.end(); iter++)
{
cout << "map.first:"<< iter->first<<endl;
cout << "map.second:"<<iter->second.<< endl;
}
}