// From Stoustrup, The C++ Programming Language, 3ed ed, page 588. // Illustrates value semantics of C++ strings. #include #include void g(){ std::string s1{"Knold"}, s2{"Tot"}; s1 = s2; // Now s2 is "Tot" and s1 is another copy of "Tot". s2[1] = 'u'; // s2 is mutated. Now "Tut". std::cout << s1 << " og " << s2 << std::endl; // Tot og Tut } int main(){ g(); }