Pointers and references look very different, pointers use the * and-I operators, and references use the. operator, but they seem to do something similar.
First, the requirement is confirmed that C + + has no null reference (null reference), that a reference must always represent an object, so it cannot point to NULL, cannot declare a variable without assigning an initial value, and cannot change its point (in fact, to use a reference more appropriately) in the process. If the above conditions are not met, consider using pointers.
Using a reference may be more efficient than a pointer, because the reference does not need to check for empty conditions.
There are also situations where references need to be used, such as when implementing certain operators. The most common case is [], this operator needs to return something that "can be used as a assignment assignment object".
e.g.:vector<int> V (10);
v[5]=10;//This is a reference, if the pointer is the words should be *v[5]=10;
Article 1: Careful distinction between pointers and references