3 ms·
I have used the goto statement to implement enumerators classes in C++ using a state member and a switch statement with goto statements at the start of the meth
by fjfaase 5y ago
I have used the goto statement to implement enumerators classes in C++ using a state member and a switch statement with goto statements at the start of the method. Of course, also all local (loop) variables need to be replaced by (private) members. At each 'yield' location, you set the state variable, have a return statement, followed by a label.
It is also possible to do this in C with functions and structs. See for example: https://www.iwriteiam.nl/Ha_cmt.html https://www.iwriteiam.nl/Ha_cmt.html