I am trying to verify the answer(s) given on a similar question. I have a trouble with them, as the below code shows that effectively the content of std::string is compared with the content of char[], not the pointer(s).. as those answers suggest.
Is this a new feature of C++11? Any help highly appreciated.
std::string smth = "hello";
char ch[8] = "hello";
if (ch == smth)
cout << "yes!";
else
cout << " no ";
ch[2] = 'W';
if (ch == smth)
cout << "yes!";
else
cout << " no ";
ch[2] = 'l';
if (ch == smth)
cout << "yes!";
else
cout << " no ";
the output is: yes! no yes!, while the pointers definitely do not change..