C + + Primer Fifth Edition essay-January 6, 2015

Source: Internet
Author: User

Record some of the things you read about this book.

I. References (reference)

The reference has a different name for the object. For example:

int ival=1024;

int &relval1=ival;//to, attention try not to use this way:int& relval=ival;

int &relval2;//error, reference must be initialized

When a reference is defined, the program binds the reference with its initial value (binding) instead of copying the initial value to the reference. Once the initialization is complete, the reference will always be bound together with its initial value object. Because the reference cannot be re-bound to another object, the reference must be initialized.

Note the following definition methods:

int i=0;

int &relval=i, R=i;////relval is a reference, R is not

int &relval=i, &r=i;//relval, and R are all references

Second, the pointer (pointer)

The type of pointer you see today is primarily a simple definition of pointers and uses that do not involve difficult applications and subsequent additions.

Third, reference and pointer mixing

int i=3;

int &r=i;

int *p=&i;

int *&R1=P;//R1 is a reference to a team pointer p

Because a reference is not an object, you cannot define a pointer to a reference.

C + + Primer Fifth Edition essay-January 6, 2015

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.