C ++ Primer learning summary chapter 1 statements, Chapter 4 primer

Source: Internet
Author: User

C ++ Primer learning summary chapter 1 statements, Chapter 4 primer
Chapter 1 Statements

1. The case label in the switch must beInteger constant expressionCannot be a variable or a non-integer type:


Note that the second case 3.14 can be executed without errors in C ++ 11, but the compilation fails in C ++ 98.

 

2. Note the following when the case statement of the switch statement initializes a variable:


The Case statement cannot skip the initialization of variables, but can skip the definition of variables.

 

3. The range for statement can not only declare variables using auto:


HoweverFor arrays, Use the range for statementBe careful

 

4. The goto statement cannot skip variable initialization. you can skip the definition of variables:


 

5. SimpleException HandlingSample Code:



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.