Jump to content
  • Advertisement

Archived

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

Drakkcon

When would I use goto in C++?

This topic is 5302 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
Read.
Read.
Read.

But make sure you read this one, which is the most concise and informative on the proper use and behavior of goto.

Thread closed. No need to rehash those multi-page discussions.

Share this post


Link to post
Share on other sites

This topic is 5302 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!