Problem in code

How to clear a string?I have a data member const std::string& n.I need to clear n value when i give an invalid input.I tried the below code:
n.clear();//not working
n.erase();//no instance of overloaded function.
memset(n,0,sizeof n);//no conversion from const std::string to void* exists.

Let me know what is the correct way to clear a string.
If it's const, that means you can't change it. Calling clear() should give you a compile time error.
Topic archived. No new replies allowed.