Jump to content
  • Advertisement

Archived

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

When would I use goto in C++?

This topic is 5153 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
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 5153 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!