I just started learning c++
. [MinGw
, c++14
].
If I want to transfer the control of a program to certain part of the code such that the control doesn't flow to any other part of the code. which is more efficient ?
switch
with goto
statement and dividing the program into fragments by using {..}switch
with function call
pls. suggest if there's an other way more efficient than these 2 mentioned above!
I totally depend upon what you want to do. As you might know, everything that is achieved using goto can be done using the 3 flows sequences, selection and iteration it's not a good practice to use goto as it violates structured programming. As for purely choosing which would be more efficient in terms of performance goto might lead by a very insignificant margin.