+ 1
Is "case:" works like instruction "goto:" ( label) in i.e. Pascal? It allows to omit some part of code.
I didnt finish C++ course but I would like to know have I good intuition. I realized that case works only with "switch". Lack of "break" gives me that remark.
2 Réponses
+ 2
Nope, case is not an analog of goto. Just forget about goto, consider it was a bad dream)))
Generally, switch-case (and yes, case statement is used only inside switch statement) is a more convenient way to handle multiple if-elseif-...-else statements, but just for 1 integer variable (for c++, in js you can pass strings, floats or whatever).
Also, it could be used for some custom behavior, but this comes with experience.
+ 1
Thank you. "Goto" was usefull in Assembler where lines had numbers (10, 20, 30 and so on). My old habit...