C + +: Why Goto is useless

Source: Internet
Author: User

To understand whether a feature is available, you should first analyze all the features it can achieve.

Goto can achieve only two functions: one, jump forward, two, jump to the back. These two cases correspond to three functions: one, repeated execution is the loop, two, skipping a piece of code is conditional judgment, three, skipping a loop of code is also jumping out of the loop. Now that there is a loop system like while, there are similar if. else, such as the condition of judgment, there are similar to break out of the cycle, such as the nature of the "goto" is not strict and troublesome design because the function is completely covered and eliminated.

Actually Goto should be the old ancestor of all the functional systems that cover it, including all possible, just because the function too much classification is unclear, resulting in the use of inconvenient so was replaced by the separate. From the very nature of the machine code, the original form of the implementation of all functions is the jump of code.

The only difference is that if: Else is an additional feature that is added only through its own selective jump mechanism, and also includes the Goto function. The Goto itself also relies on the If this additional judgment function.

C + +: Why Goto is useless

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.