C + + refers to what is used to do, what is the benefit of __c++

Source: Internet
Author: User
C language without reference, C + + only.

References can act as part of a pointer, but are more secure than pointers.

A reference can be thought of as an "alias" of a variable. Manipulating a reference is like manipulating the original variable. Used

primarily for parameter passing of a function. Because C language does not have similar VB "Pass reference call" This function, so the reference of C + + fills this blank. Since then, even if you need to change the parameters, but also directly pass a variable past can be. This is of greater importance in operator overloading.
int A;  Declare variable a
int& RA = A;//declare a reference, the name is Ra,ra reference a

note, the RA declaration must also give a reference to who it actually refers to
int& RA;

also, once a reference is declared, it cannot be modified to another variable, which is different from the pointer.
RA = b;//This is not going to work because it's already int &ra = a
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.