C/C ++: essence of left value (2) which expressions are left values and right values? -- Left expression

Source: Internet
Author: User

Essence of C/C ++ left

(2) which expressions are left and right?

 

1. Left expression

 

As described in the previous section, the left value has an object or an incomplete type. In C ++, it also has a function or reference type. However, an expression that does not have the above type is the left value, the key is that the Left value must indicate an object. Whether the object is valid or invalid, complete, or incomplete, it contains functions other than non-static member functions in C ++. For example:

 

Int I;

Int * P = & I;

 

Both I and P indicate an object and have an object type, so they are both left values. & I, although it has an object type, is not left because it does not indicate an object.

Incomplete types can also be left values, because incomplete types are essentially the same as object types, but they do not have complete object information. Forward Declaration is the most commonly used incomplete type. The reference to forward declaration is allowed. For example:

 

Extern struct s;

S & R = s;

 

Although the complete definition of S is not visible, it can still be used as the left value to initialize the left value reference.

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.