fork download
  1. #include<iostream>
  2. #include<string>
  3.  
  4. class A {
  5. private:
  6. int i;
  7. std::string s;
  8. public:
  9. A(int ii, std::string ss = "Hello") { i = ii; s = ss; }
  10. void Display() { std::cout<<i<<"\n"; }
  11. ~A() { std::cout<<"A::~A()"<<"\n";}
  12. };
  13.  
  14. void function()
  15. {
  16. A a = 1;
  17. A b = A(1);
  18. a.Display();
  19. b.Display();
  20. }
  21.  
  22. int main()
  23. {
  24. function();
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
1
1
A::~A()
A::~A()