// Illustrates reference semantics of C-like strings. // Compiles with warnings, but does probably not execute correctly (likely: segmentation fault). #include void g(){ char *s1 = "Knold", // Compiler Warnings: *s2 = "Tot"; // deprecated conversion from string constant to char* s1 = s2; // Both s1 and s2 points to the same "Tot" C-style string. s2[1] = 'u'; // Expected run-time error here, because literal strings in the program a non-mutable. std::cout << s1 << " og " << s2 << std::endl; } int main(){ g(); }