fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class LoopVar
  6. {
  7. public:
  8. ~LoopVar();
  9. };
  10.  
  11. LoopVar::~LoopVar()
  12. {
  13. cout << "Destructor running..." << endl;
  14. }
  15.  
  16. int main()
  17. {
  18. int k = 0;
  19. LoopVar start;
  20. for(LoopVar l = start;;)
  21. {
  22. cout << "Iteration " << k++ << endl;
  23. if(k == 10)
  24. break;
  25. }
  26. cout << "End of loop" << endl;
  27. return 0;
  28. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
Iteration 0
Iteration 1
Iteration 2
Iteration 3
Iteration 4
Iteration 5
Iteration 6
Iteration 7
Iteration 8
Iteration 9
Destructor running...
End of loop
Destructor running...