Difference between reference and pointer in C++

1. References must be initialized when they are created; while pointers can be created first and then initialized.

2. References cannot be initialized to NULL; but pointers can be initialized to NULL.

3. The meaning of the ++ operator is different. ++ for a reference is an increment of the value; ++ for a pointer is an increment of the address.


Guess you like

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