str string; str[0]='a' - undefined, " ++ 11" " ++ 11 on". , str . , ++ 11 (read) , str[pos] pos == size() str , undefined. ++ 11, ( '\0'. undefined.
Cpp std:: basic_string:: operator_at.
, , ; ( ):
string str = "bbbb";
const char* cstr = str.data();
printf("adress: %p; content:%s\n", cstr, cstr);
str[0] = 'a';
const char* cstr2 = &str[0];
printf("adress: %p; content:%s\n", cstr2, cstr2);
cout << "str:" << str << endl;
, , str.data() , str.data() , &str[0].
string str = "", ( undefined, , ):
string str;
const char* cstr = str.data();
printf("adress: %p; content:%s\n", cstr, cstr);
str[0] = 'a';
const char* cstr2 = &str[0];
printf("adress: %p; content:%s\n", cstr2, cstr2);
cout << "str:" << str << endl;
, str.data() , &str[0], 'a' ( , , , , , ). str.data() a ( , 'a' , char). str[0]='a' , 0, cout << str .
, -.