0

Hi, all
I am trying to write the function to get rid of my punctuations.
My code:

//_word_list is the vector<string> type
void TextUtil::isnotpuct() const
{	for(size_t i=0; i<_word_list.size(); i++)
	{
		size_t len = _word_list[i].length() + 1;
		for(size_t j=0; j< len;j++)
		{  if(ispunct(_word_list[i][j]))
			{  
				_word_list[i] = "";
			}
		   
		   j++;
		}
		i++;
     }

}

But i got the error:

error C2440: '=' : cannot convert from 'const char [1]' to 'const char'

Where is the problem with my code??
Many thanks.

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by ArkM
0

How many times are you planning to post this code ?
I've already seen variations of this code in at least three different threads, but all with a similar question: "This code isn't compiling ..."

I'm not blaming you for this because it's a moderator's task to make a judgment about whether this is allowed or not ...

0

That's your problem:

void TextUtil::isnotpuct() const
{
//_word_list is the vector<string> type
...
_word_list[i] = "";
...

const member function can't modify other members. WHY this function-predicate has so drastic side effect?!

Yes, it's a ghost post... May be once morning this code will be compiled successfully...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.