Why use references when pointers can do everything references can do?

Showing Answers 1 - 7 of 7 Answers

rajat kumar patel

  • Mar 27th, 2006
 

in references to memory block

  Was this answer useful?  Yes

Vedika

  • Mar 27th, 2006
 

hi

References are used when the refered variable cotent are constants. Where as the content of pointer variable are variant may change. So where a constant reference to a variable is required references are used instead of opinters. Best example is in copy constructors one has to use references instead of pointers.

Regards,

Vedika

  Was this answer useful?  Yes

sanneeta

  • Apr 5th, 2006
 

using pointers are more complex, while using references are simpler to understand.

The indirection is hidden, and there is no need to repeatedly dereference the variable in case of references.

Though pointers are difficult to use, they offer more flexibility.  References cannot be null and they cannot be reassigned.

  Was this answer useful?  Yes

lakshmi narasimha rao

  • May 9th, 2006
 

pointers can do everything but it isdifficult & complex when compare to references.

  Was this answer useful?  Yes

Visitor

  • Oct 9th, 2007
 

With pointers you can do pointer arithmatic like increment or decrement the pointer.

You cant do that with reference.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions