fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. class A
  6. {
  7. public:
  8. A()
  9. {
  10. cout << " A C_tor" << endl;
  11. }
  12. A (const A& obj)
  13. {
  14. cout << " A copy C-tor" << endl;
  15. }
  16. ~A()
  17. {
  18. cout << "A's D-tor" << endl;
  19. }
  20. };
  21. void fn(A& obj)
  22. {
  23. cout << "fn A " << endl;
  24. }
  25. int main() {
  26. // your code goes here
  27. //A obj;
  28. //fn(obj);
  29. vector<A> vecA;
  30. A obj;
  31. vecA.push_back(std::move(obj));
  32. vecA.pop_back();
  33. cout << "pop_back called" << endl;
  34. return 0;
  35. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
 A C_tor
 A copy C-tor
A's D-tor
pop_back called
A's D-tor