C ++ [comma operation]

Source: Internet
Author: User

The comma operation is a relatively small operation.

 

The form of a comma expression is as follows:

Expression 1, expression 2, expression 3,..., expression n

Essentials of a comma expression:

(1) The comma expression is calculated from left to right. That is, its entire value is the value of the last expression.
(2) The comma expression is used as a whole, and its value is the value of the last expression (that is, expression n.
(3) The priority of the comma operator is not the lowest among all operators.

Example:

I = (a = 2*3, a * 5), a + 6;

Result: I = 30

Analysis:

A = 2*3, a * 5 is a comma expression, and the calculated value is 30. I = (a = 2*3, a * 5) constitute an assignment statement, the value assignment statement and a + 6 constitute a comma statement.

 

Similarly, you can analyze the following results ~

I = (a = 2*3, a * 5), a + 6 );

Result: I = 12

 

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.