• Advertisement

Archived

This topic is now archived and is closed to further replies.

When would I use goto in C++?

This topic is 5064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there ANY situation in which it would be acceptable coding style to use the goto command? The true general first seeks victory, then seeks battle - Sun Tzu

Share this post


Link to post
Share on other sites
Advertisement
Probably not. Functions can serve the same purpose as a goto. You never know, just keep coding and maybe you will find an exception.

Share this post


Link to post
Share on other sites
Opinions are divided. Some people think it''s acceptable to use them to break out of nested loops. Some people do not. Other than that, I am not aware of any general situation where they are considered anything but Harmful.

Share this post


Link to post
Share on other sites
So like what Miserable said, it would be acceptable to use goto in the place of break if I wanted to? Come to think of it I can't see a single situation where I'd use that...

[edited by - Drakkcon on April 12, 2004 2:01:42 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Drakkcon
So like what Miserable said, it would be acceptable to use goto in the place of break if I wanted to? Come to think of it I can''t see a single situation where I''d use that...

A break would only break out of the immediately enclosing loop. If you wanted to break out of two or more nested loops, you''d need a goto.

Java has labeled breaks just for this purpose.

Share this post


Link to post
Share on other sites

This topic is 5064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.

  • Advertisement