What is the difference between reference and pointer?
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.
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.
C++ (or “C-plus-plus”) is a general-purpose programming and coding language. C++ is used in developing browsers, operating systems, and applications, as well as in-game programming, software engineering, data structures, etc.
In brief, the main differences between references and pointers in C++ are:
Initialization: References must be initialized when declared and cannot be reassigned, while pointers can be declared without initialization and can be reassigned to point to different objects.
Nullability: References cannot be null or uninitialized, whereas pointers can be null or left uninitialized.
Syntax: References are declared using & and do not require dereferencing, while pointers are declared using * and require dereferencing with * to access the pointed-to object.
Memory Address: References do not have their own memory address; they are an alias for an existing object. Pointers have their own memory address, representing the location of the pointed-to object.
Reassignment and Aliasing: References cannot be reassigned to refer to a different object, always referring to the same object they were initially bound to. Pointers can be reassigned, allowing for flexibility and aliasing.
Null Pointer Dereference: Dereferencing a null pointer leads to undefined behavior. Dereferencing a reference is always safe, as it refers to a valid object.
Function Arguments: References are commonly used for passing arguments to functions, enabling direct modification of the original object. Pointers can also be used but require explicit dereferencing.
In summary, references provide a convenient way to create an alias for an object, while pointers offer more flexibility with reassignment and nullability.
A reference variable gives an existing variable a new name. It is implicitly dereferenced and does not require the dereferencing operator * to access the value referenced. A pointer variable, on the other hand, stores an address. The address value contained in a pointer can be changed.

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 ‘ * ‘