1.

What Are The Difference Between Reference Variables And Pointers In C++?

Answer»

Pointers:

  • Pointers can be assigned to NULL
  • Pointers can be (re)pointed to any OBJECT, at any TIME, any number of times during the execution.
  • Pointer has own memory address and location on stack

Reference Variables:

  • References cannot be assigned NULL. It should ALWAYS be associated with actual memory, not NULL.
  • Reference variables should be initialized with an object when they are CREATED and they cannot be reinitialized to REFER to another object
  • Reference variables has location on stack, but shares the same memory location with the object it refer to.

Pointers:

Reference Variables:



Discussion

No Comment Found