fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Widget
  6. {
  7. public:
  8. Widget(){cout << "ctor" << endl;}
  9. ~Widget(){cout << "dtor" << endl;}
  10. void print(int i){cout << i << endl;}
  11. };
  12. int main()
  13. {
  14. int i = 0;
  15. while( i++ < 5)
  16. {
  17. Widget o;
  18. o.print(i);
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
ctor
1
dtor
ctor
2
dtor
ctor
3
dtor
ctor
4
dtor
ctor
5
dtor