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.