What is the difference between reference and pointer?
Shathana. S.R. Answered question July 6, 2023
Memory Address:Â A pointer has its own memory address and size on the stack, whereas a reference shares the same memory address with the original variable but also takes up some space on the stack.
Shathana. S.R. Answered question July 6, 2023

Reference
Pointer
The value of a reference cannot be reassigned The value of a pointer can be reassigned
It can never hold a null value as it needs an existing value to become an alias of It can hold or point at a null value and be termed as a nullptr or null pointer
It cannot work with arrays It can work with arrays
To access the members of class/struct it uses a ‘ . ‘ To access the members of class/struct it uses a ‘ -> ‘
The memory location of reference can be accessed easily or it can be used directly The memory location of a pointer cannot be accessed easily as we have to use a dereference ‘ * ‘