Home / Object Oriented Programming / Difference between Reference variable and Pointer variable

Difference between Reference variable and Pointer variable

Difference between Reference variable and Pointer variable

Reference Variable Pointer Variable
A reference can be used directly A pointer needs to deference with * to access memory location
A reference to a class/struct uses (.) to access its members A pointer to a classy class/struct uses ‘->’ to access its members
A reference has the same memory address as the item it references A pointer that holds a memory address
Reference cannot be assigned Null directly A pointer can be assigned NULL directly
Reference cannot be re-assigned A pointer can be re-assigned