1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <iostream> using namespace std; class LoopVar { public: ~LoopVar(); }; LoopVar::~LoopVar() { cout << "Destructor running..." << endl; } int main() { int k = 0; LoopVar start; for(LoopVar l = start;;) { cout << "Iteration " << k++ << endl; if(k == 10) break; } cout << "End of loop" << endl; return 0; } |
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIExvb3BWYXIKewoJcHVibGljOgoJfkxvb3BWYXIoKTsKfTsKCkxvb3BWYXI6On5Mb29wVmFyKCkKewoJY291dCA8PCAiRGVzdHJ1Y3RvciBydW5uaW5nLi4uIiA8PCBlbmRsOwp9CgppbnQgbWFpbigpCnsKCWludCBrID0gMDsKCUxvb3BWYXIgc3RhcnQ7Cglmb3IoTG9vcFZhciBsID0gc3RhcnQ7OykKCXsKCQljb3V0IDw8ICJJdGVyYXRpb24gIiA8PCBrKysgPDwgZW5kbDsKCQlpZihrID09IDEwKQoJCQlicmVhazsKCX0KCWNvdXQgPDwgIkVuZCBvZiBsb29wIiA8PCBlbmRsOwoJcmV0dXJuIDA7Cn0=
-
upload with new input
-
result: Success time: 0.02s memory: 2724 kB returned value: 0
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...


