Difference Between Pointer and Reference

pointer: point to a variable

reference: bind to a variable

First, the pointer itself is an object, allowing assignment and copying of the pointer, which can point to multiple objects. A reference is not an object, and there is no way to rebind a reference to another object.

Second, the pointer does not need to be initialized, it will have an indeterminate value if it is not initialized, and the reference must be initialized when it is defined.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325886259&siteId=291194637