Hi, all
I got stuck by the erase function usage.
here is my code:

//A is my class
//this function is used for judge weather there is a punctuation in //the word and get rid of it.
void A::isnotpuct(const string& wordlist) const
{
	size_t len = wordlist.length() +1;
	for(size_t j=0; j<wordlist.length();j++)
	{  if(ispunct(wordlist[j]))
		{  
			size_t lenend = len-j;
			   wordlist.erase(wordlist.begin()+j,wordlist.end()-lenend);
		}
	}
}

But i got the error information:

error C2663: 'std::basic_string<_Elem,_Traits,_Ax>::erase' : 3 overloads have no legal conversion for 'this' pointer

What does that mean??
How i could correct it??
Many thanks.

>What does that mean??
erase modifies the string, but your string is const. Well, that's not what the error means, but it's the root cause. ;)

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.