fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. std::string foo() { return "bar"; }
  5.  
  6. int main()
  7. {
  8. std::string s = "hello";
  9. std::cout << s << std::endl;
  10. foo().swap(s);
  11. std::cout << s << std::endl;
  12. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
hello
bar