Вход на сайт
Programmierung Quereinsteiger?
3536 просмотров
Перейти к просмотру всей ветки
в ответ uscheswoi_82 29.12.21 19:46, Последний раз изменено 29.12.21 20:38 (uscheswoi_82)
А в Си++ так
У них (у переменных s и s2) даже адреса разные:
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char** argv) {
string s = "Hello, World!";
string s2 = s;
cout << "Pointer of variable \"s\"=" << &s << "\n" << "Pointer of variable \"s2\"=" << &s2 << endl;
cout << s2 << endl;
s = "";
cout << s2 << endl;
}
Результат:
Pointer of variable "s"=0x23fe30 Pointer of variable "s2"=0x23fe20 Hello, World! Hello, World! -------------------------------- Process exited after 0.02382 seconds with return value 0 Drücken Sie eine beliebige Taste . . .
Если я кому-то отвечаю, это не значит что я ему симпатизирую, каждый остаётся при своём мнении
Моя ФЛ Он и Она
Моя ФЛ Он и Она