Suppose the following code:
#include <iostream>
#include <string>
int func() { return 2; }
int main()
{
std::string str("str");
str = func();
std::cout << "Acquired value: '" << str << "'" << std::endl;
return 0;
}
Why does the line str = func(); compile without warning of a type mismatch?
I'm using compiler gcc v. 4.7.1 with the -std=c++11 flag set.
Output:
Acquired value: ''