c++ - Issue with string::operator+= -


i tried append 2 letters string, seems string not changed:

void fun() {     string str;     str += 'a' + 'b';      cout << str; } 

i checked source code of stl , found implementation of operator+=, still don't know why.

basic_string& operator+=(_chart __c) {     this->push_back(__c);     return *this; } 

by adding 'a' + 'b' have 2 chars added form char. add string +=.

this code want:

std::string str; ( str += 'a' ) += 'b';  std::cout << str; 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -