Question:

What are the difference between reference variables and pointers in C++?

Answer:

[This question is usually asked in a twisted way during c++ interviews. Sometimes the interviewer might use examples and ask you to find the error.]

Pointers Reference Variables
Pointers can be assigned to NULL References cannot be assigned NULL. It should always be associated with actual memory, not NULL.
Pointers can be (re)pointed to any object, at any time, any number of times during the execution. Reference variables should be initialized with an object when they are created and they cannot be reinitialized to refer to another object
Pointer has own memory address and location on stack Reference variables has location on stack, but shares the same memory location with the object it refer to.

Keywords:

© 2017 QuizBucket.org