fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. struct AAA {
  5. std::string a, b;
  6. };
  7.  
  8. AAA &getRef() {
  9. AAA aaa = {"the first item", "the second item"};
  10. return aaa;
  11. } // 'aaa' is absolutely destroyed here, no doubt about it!
  12.  
  13. int main() {
  14. AAA &ref = getRef();
  15. std::cout << ref.a << ", " << ref.b << std::endl;
  16.  
  17. return 0;
  18. }
Runtime error #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
the first item!����the second item�