Hi, all
its me again!
I got really stuck by the STL library and do not know how to correct that.

Here is my class code:

class A
{
public:
    A( const string& filename )
    {
       ifstream file(filename.c_str()) ;
        string word;
       while( file >> word)
       {
	  _word_list.push_back(word);
        }
      }
    StringIntVector topNWords(size_t n) const;
     bool isnotpuct() const;
    // this function is to judge weather the text inside the file
    // is punctuations.
private:
    vector<string> _word_list;

};

Here is my isnotpuct() function

bool TextUtil::isnotpuct() const
{
        for(size_t i=0; i<_word_list.size(); i++)
     {
       for(size_t j=0; j<_word_list[i].length();j++)
        if(ispunct(_word_list[i][j]))
            return false;
        else
            return true;
      }
}

Here is my topNWords function

//stringvector is the type--
//typedef vector< pair < string, int > > StringIntVector;

StringIntVector TextUtil::topNWords(size_t n) const
{
    map<string, int> freq;
   StringIntVector vRet;
    for(size_t i=0; i<_word_list.size(); i++)
  {
     if(isnotpuct())
    {
      string words = _word_list[i];
      size_t topn = wordCount(words);
      freq[words] = topn;
    }
   }
    sort(freq.begin(),freq.end());
    map<string, int>::const_iterator iter;
    for (iter=freq.begin(); iter != freq.end(); iter++)
    {
        vRet.push_back(*iter);
    }
      return vRet;

So i got the error message

Error    2    error C2784: 'bool std::operator ==(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::basic_string<_Elem,_Traits,_Ax>'

Which i was thinking it may caused by the bool isnotpuct() function
am i correct??
So how to correct it??
Many thanks.

What exactly is wordCount counting? Aren't you passing it a single word?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.