A ++ and ++ a left values

Source: Internet
Author: User

A ++ and ++ A, the prefix and suffix can be used as the left value. This problem has made me busy for a long time and finally made some breakthroughs.

A ++ and ++ A are different when doing the left value. Therefore, the left value must first have a specific address before it can be used as the left value. Otherwise, no specific object is assigned. Let's take a look at a ++ and ++. A ++ means to copy a temporary data to participate in the calculation of the surrounding environment, and then add the variable, it can be seen that a ++ is used to perform computation on a temporary copy of data. This data temporarily exists without a fixed address, rather than a real variable. ++ A means to add the variable a first and then place the variable in the surrounding environment for calculation. Then ++ A is used to calculate the variable with a specific address, therefore, ++ A can be used as the left value.

It can be understood:

A ++ returns a temporary variable.

++ A returns a reference to a variable.


Notes:

Calculating the space occupied by a struct does not simply add the space occupied by each member. Considering the requirements of system boundary alignment, the sizes of the following two structs are not the same.

Struct funp
{
Int;
Char B;
Char C;
};

The size is 8 bytes.

Struct funp
{
Char B;
Int ;;
Char C;
};

The size is 12.

The size of the above two struct types is 8 bytes and 12 bytes respectively, which is not a simple addition of 6 bytes. We need to consider the 4-byte alignment.



A ++ and ++ a left values

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.