Pointer vs. reference - C++

Pointer vs. Reference.

- When a reference is created, it can’t reference another object. This can be done with pointers. References cannot be null whereas pointers can be. References cannot be uninitialized and it is not possible to refer directly to a reference object after it is defined.
- Syntax of reference :
<Type> & <Name>
- Example :
int& rA = A; rA is a reference to int.

Pointer vs. Reference.

- A reference must be initialized at the time of declaration whereas not needed in case of pointer. A pointer can point to a null object.
- A reference once initialize to refer to the object can't be reassigned to refer to other whereas reassignment is possible with pointer.
Explain how to call C functions from C++
Explain how to call C functions from C++ - The extern keyword is used to call C functions from C++...
How to declare a class as a friend of another class - C++
How to declare a class as a friend of another class..
Class vs. Structure - C++
Class vs. Structure - Class has private as default access specifier.Default inheritance type is private......
Post your comment
Discussion Board
C++
Thankx for giving m lot of information about the reference.
Bhagyshri Gurav 08-8-2012