I have a code that compiles, and it looks like:
void test1(const std::string &name)................
test1("myName");
But, if I remove the const
from the declaration as:
void test2(std::string &name)................
test2("myName");
The code just doesn't compile.
Why the const std::string
makes it compile? As far as I understand the same implicit constructor will be called for the char *
to be converted to a std::string
.
I am using Visual Studio 2013, in case this might be related to the answer.