A reference is an alias, which is essentially a pointer, and the implementation of a reference is simply a constant pointer to a particular object. The object is manipulated directly when referencing a parameter, reducing the cost of copying when the value is passed.
So the copy constructor parameter type is (const type & ...), and by the way copy is constructed to copy the object in a custom manner, avoiding the compiler's shallow copy behavior.
So what are the similarities and differences between pointers and references:
1, the reference must be initialized; pointers are not required (the compiler will not error, but this behavior will be hidden);
2, the reference is an alias, its size is related to the referenced object, and the pointer is an address, the size of the same (32-bit system, 64-bit system);
3. After the reference is initialized, the referenced object cannot be changed, and the pointer can change to point to the object;
4, pointers with pointers, that is, two-level pointers, but no reference;
5, no reference pointer; But a pointer reference, such as int*& &, is int*, and the effect is equivalent to two level pointers;
6, an array of pointers, such as char* arr[]; There is no reference to the array, but there is an array of references;
References and pointers