fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. int a;
  7. public:
  8. A(int x):a(x){cout<<"constructor"<<endl;}
  9. ~A(){cout<<"destructor"<<endl;}
  10. void print(){
  11. A temp(20);
  12. cout<<temp.a<<endl;}
  13. };
  14.  
  15. int main() {
  16. // your code goes here
  17. A obj(10);
  18. obj.print();
  19. //cout<<<<endl;
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
constructor
constructor
20
destructor
destructor