Google News
logo
CPP - Quiz(MCQ)
Why references are different from pointers in C++?
A)
A reference cannot be made null
B)
A reference cannot be changed once initialized
C)
No extra operator is needed for dereferencing of a reference
D)
All of the mentioned

Correct Answer :   All of the mentioned


Explanation : * References are used to refer an existing variable in another name whereas pointers are used to store address of variable.

* References cannot have a null value assigned but pointer can.

* A reference variable can be referenced by pass by value whereas a pointer can be referenced but pass by reference.

* A reference must be initialized on declaration while it is not necessary in case of pointer.
 
* A reference shares the same memory address with the original variable but also takes up some space on the stack whereas a pointer has its own memory address and size on the stack.

Advertisement