in class words i defined string and int for count
Code:
class words
{
private:
string s;
int count;
public:
words() : s(""), count(1)
{}
words(const string st, int counting) : s(st), count(counting)
{}
string getWord() const
{
return s;
}
int getCount()
{
return count++; // count will automatically increase when callled
}
bool operator == (const words &other) const
{
return (s == other.s);
}
bool operator != (const words &other ) const
{
return (s > other.s);
}
bool operator < (const words &other ) const
{
return (s < other.s);
}
string toString() const
{
stringstream ss;
ss << " " << count << " | " << s;
return ss.str();
}
};
but the result still 1, doesn't increase at all.
Code:
for(itr = token.begin();itr!=token.end();itr++)
{
w.getCount();
new_word = *itr;
if (!word.find(words(new_word, count)))
{
count = 1;
word.insert(words(new_word, count));
new_word.clear();
}
else
{
w.getCount(); // i don't know is it enough for increment
}
}
the result only 1 for every word.