C + + comma operator

Source: Internet
Author: User

1. The result of the comma operator is that the result of the last formula

2. The comma operator is the lowest priority, and the operator precedence is lower than the equals sign

1  intA =2;2             intb =3;3             intc = A, b++,a+b;4             //The result is C = 2, because the equal value operator takes precedence over the comma operator, and the assignment operation is performed first .5A =2;6b =3;7c = (a++,b++,a+b);8             //The result is C = 7; the parentheses have high precedence, first the operation in parentheses, and C = The result of a Chinese sub-bracket9             //The comma operation in parentheses, the result of the final formulaTen             //a++ Results A = 3; b++ results b=4; a+b =7;

C + + comma operator

Related Article

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.