J
Jarek Blakarz
why no compilation error
The following piece of code compiles fine.
I expected it not to compile.
I thought that fun("sth") creates temporary "string" object that cannot be
assigned to lvalue string reference.
It turns out that I was wrong.
Please help me understanding what is going on here and why it is correct.
thanks.
void fun(const string &s) {}
int main(void)
{
fun("sth");
return 0;
}
The following piece of code compiles fine.
I expected it not to compile.
I thought that fun("sth") creates temporary "string" object that cannot be
assigned to lvalue string reference.
It turns out that I was wrong.
Please help me understanding what is going on here and why it is correct.
thanks.
void fun(const string &s) {}
int main(void)
{
fun("sth");
return 0;
}