ok i understand assign() by viewing www.cppreference.com
really thanx laserlight .. you are brilliant...
one more question which i dont really understand why i could not display wat i want....
this is my class = header file
Code:
#include <string>
#include <iostream>
#include <vector>
#include "stringset.h"
using namespace std;
class InvertedIndex
{
//insert data member here
struct inputType
{
string word;
StringSet file;
};
vector<inputType> list;
public:
// Tally adds one word/file pair to the index
void tally(string word, string file);
and this is my implementation code
Code:
#include "inverted_index.h"
#include "osdir.h"
// 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)
{
inputType input;
list.push_back( input );
}
// print
// Pre: an index structure
// Post: renders the index on the screen
void InvertedIndex::print()
{
for( vector<inputType>::const_iterator output = list.begin(); output != list.end(); output++ )
cout << "Word: " << output->word << "\t\tFile: " << output->file << endl;
}
and the main code
Code:
#include "inverted_index.h"
int main()
{
// test the InvertedIndex
InvertedIndex idx;
idx.tally("cat", "cats.txt");
idx.tally("cat", "animals.txt");
idx.tally("cat", "everything.txt");
idx.tally("dog", "dogs.txt");
idx.print();
why the output is empty. ??