Pointers and references look very different (pointers use
->, while references use
.), but they seem to have the same function: both can be used to indirectly point to another object. So when should you use pointers vs. references?
The most important thing you should always remember is that, reference can never be assigned
NULL directly. A reference has always to refer to an object. Therefore, if you need a variable that needs to point to nothing sometimes, then this variable should be declared as a pointer, not a reference. The fact that reference should always refer to an object makes the program more effective, because it doesn’t need to be tested
null before usage.