C + + Primer Learning Summary 4th Chapter Expression

Source: Internet
Author: User
Tags bitwise operators

4th Chapter Expressions


1. When Decltype acts on an Lvalue object, it returns the reference type of the object. When acting on an Rvalue object, the type of the object is returned.



2. Order of Evaluation.


In C + + only && | |?: and , 4 operators are evaluated first left and right.

3. The unary plus sign operator acts on the value:


the type that will raise the current value , like Short become int type

4. The results of m% (-N) and (-M)%n with (-m)% (-N) are:


Note : The sign of the module has no effect , M The positive and negative results of the decision .

5. The relational operator satisfies the left binding law:


6. When is the increment decrement operator (such as ++x,x++) not replaceable (in the form of x+1)?

when used with iterators that do not support arithmetic operations , is a must. .

7. + +,--operator, the predecessor version returns an Lvalue object, and the back version returns an Rvalue object.


8. The post-increment operator takes precedence over the dereference operator



9. Operands can be evaluated in any order:



10. The conditional operator satisfies the right binding law:



One. bitwise operators are strongly recommended for handling unsigned or positive numbers only, because how the symbol bits are handled is machine-related.


The object of a struct struct class is a word size that needs to be aligned.



The sizeof operator does not calculate the value of its operand, so it is legal to dereference an invalid pointer in sizeof.

When sizeof acts on string and Vecvtor, only the byte size of its fixed portion is returned, and its contents are not byte-sized.

14. The Order of evaluation for the comma operator is left-to-right and its return value is the value of the right expression. So if the return value of the right expression is an lvalue, then the return value of the comma operator is also an lvalue. Note b=4 returns A reference to b ( that is, the left value )

Void* can store any address of a very important object :

Const_cast<> () will change ( and only change ) the underlying const Property of the operand. (Only pointers and references have the underlying const)


C + + Primer Learning Summary 4th Chapter Expression

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.