fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. std::string x("Hello");
  6.  
  7. std::string y = x; // x and y use the same buffer
  8.  
  9. y += ", World!"; // now y uses a different buffer
  10. // x still uses the same old buffer
  11. cout << x + "\n";
  12. cout << y;
  13. return 0;
  14. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Hello
Hello, World!