ops... ok here is another error...
class code
Code:
#include <string>
#include <iostream>
#include <vector>
#include "stringset.h"
using namespace std;
class InvertedIndex
{
//insert data member here
vector <string> words;
vector <StringSet> files;
public:
// Tally adds one word/file pair to the index
void tally(string word, string file);
this is the implementation
Code:
#include "inverted_index.h"
#include "osdir.h"
int InvertedIndex::size()
{
cout<<"Files size: "<<files.size()<<endl;
cout<<"Words size: ";
return words.size();
}
// InvertedIndex::tally
// Pre: a word and file pair as strings
// Post: adds the file to the index under word
void InvertedIndex::tally(string word, string file)
{
words.push_back(word);
files.push_back(file); //problem occur here
}
the main code
Code:
#include "inverted_index.h"
int main()
{
StringSet ss;
ss.insert("one");
ss.insert("two");
ss.insert("three");
ss.insert("one");
ss.print();
if ( ss.contains("one") )
cout << "ok - contains('one')\n";
else
cout << "fail - contains('one')\n";
// test the InvertedIndex
InvertedIndex idx;
idx.tally("nissan", "car.txt");
idx.tally("nissa", "carbrand.txt");
idx.tally("nissan", "everything.txt");
idx.tally("honda", "hondacar.txt");
cout <<idx.size() <<endl;
in the code, i want to store the word and file into vector
for example
vector IDX
--------------------------------------------------------
nissan | car.txt carbrand.txt everything.txt |
--------------------------------------------------------
honda | hondacar.txt |
---------------------------------------------------------