fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A {
  5. A() {cout<<"A:"<<this<<endl;}
  6. ~A() {cout<<"~A:"<<this<<endl;}
  7. void f() {cout<<x<<endl;}
  8. int x = 5;
  9. };
  10.  
  11. void f(A a) {
  12. cout<<"f"<<endl;
  13. }
  14.  
  15. int main() {
  16. // your code goes here
  17. A a;
  18. cout<<"before f"<<endl;
  19. f(move(a));
  20. cout<<"after f"<<endl;
  21. a.f();
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5436KB
stdin
Standard input is empty
stdout
A:0x7ffdf24bb540
before f
f
~A:0x7ffdf24bb544
after f
5
~A:0x7ffdf24bb540