Reference array and array reference

Source: Internet
Author: User

Today I found that I had a problem during my learning process. I always thought that referencing arrays and array references are a concept, when I was learning, I remember that there was such a sentence in the book that C ++ did not reference arrays, So I thought there was no array reference, but a problem last night made me realize that I was wrong.

In chapter 7 functions of C ++ primer version 4, there is a section about passing arrays through references. When I see this title, I will explain it. So far, I have finally understood it, it turns out that I have always misunderstood the sentence in the book.

The referenced array does not exist in C ++.

An array occupies storage space. It is actually a pointer and stores n memory addresses of the same size. The reference does not occupy memory. Therefore, if an array is referenced, the reference does not occupy memory, array occupies memory, which is mutually contradictory (if this cannot be understood, you should analyze this section and check the relevant information)

Array reference exists in C ++

Array reference is an array reference.

 

Int A = 10; Int & B =;

 

B is an int type reference. So what is the reference in the following code?

 

Int A [10]; int (& B) [10] =;

 

What is the situation? Yes, B is an array reference, which is equivalent to.

 

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.