3 ms·
Common in C. C++ should focus on RAII destructors, such as std::lock_guard. I can't think of a legitimate time to use "goto" in C++, unless you were forced to
by dragontamer 13y ago
Common in C.
C++ should focus on RAII destructors, such as std::lock_guard. I can't think of a legitimate time to use "goto" in C++, unless you were forced to emulate C for some reason.
- ternaryoperator 13y agoIt can be useful in deeply nested loops. One can certainly argue about the wisdom of deeply nested loops whose complexity requires a goto statement, but sometimes you just need to pop out of a loop to somewhere in a higher loop and goto solves that problem effectively.
- dragontamer 13y agoFair point. IIRC, Java and C# allow "break" statements to have a label associated with them specifically for this case. C++ "break" statements are all implicit. So a goto is the only thing that can solve this problem.