[Basic-C + +-written assault] 4. Operators and Precedence

Source: Internet
Author: User

Overview:

An expression that consists of operands and operators.

In the written examination, the usual test center has the operator's priority, the XOR and the equal relation operation .

4.1 Assignment Statements

The assignment operator "=", the left side of the operator represents the address of the storage unit, called the left value, and the right side of the table is the desired value, called the right value.

Note: The left operand of the assignment operator must be a non-const left value .

int Const& Max (int Const& A,int Const&b) {returna > B?a:b;}int& Fun (int&a) {a+=5; returnA;}int* FUN2 (int*a) {returnA;}intMain () {intII =Ten, j = -; Fun (ii)= -;//statement 1 correctly executed after II =printf"%d", ii); Max (II, J)= $;//Statement 2 error expression max (II, J) is not a modifiable lvalueprintf"%d", ii); Fun2 (&II) = $;//Statement 3 error cannot be converted from int to int*printf"%d", ii); *fun2 (&II) = $;//Statement 4 is correctprintf"%d", ii); System ("Pause");}

Second, the assignment operator has a right-associative property. When the expression contains multiple assignment operators, the right-to-left combination.

4.2 Self-increment and decrement operators

The prefix operation "first change after use", and then the "first change after".

Take + + as an example:

Prefix: ++a means take the address of a, add its contents, and then put the value in the Register;

Suffix: a++ represents the address of a, loads its value into a register, and then increments the value of memory a.

For personal reasons, see here first today, tomorrow continue to ^-^, not to be continued .....

[Basic-C + +-written assault] 4. Operators and Precedence

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.