fork download
  1. #include <iostream>
  2.  
  3.  
  4. class A {
  5. public:
  6. void a() const {
  7. std::cout << "a()\n";
  8. }
  9. ~A () {
  10. std::cout << "~A()\n";
  11. }
  12. };
  13.  
  14.  
  15. const A &getATheWrongWay () {
  16. return A();
  17. };
  18.  
  19.  
  20. int main () {
  21. const A &a = getATheWrongWay();
  22. a.a();
  23. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
~A()
a()