The difference between reference variable and pointer

1. The pointer variable can be defined without initialization or it can initially point to NULL.  The reference variable must be initialized properly and it can only initialized to one variable.

2. Initializing a pointer variable will assign memory space to it. The reference variable does not have its own memory space.

3. The assignment of a pointer variable changes the address it point to, while the assignment of a reference variable changes the content of that reference.

4. The pointer variable can change the memory it point to, while the reference variable can not.

Advertisements
This entry was posted in C++. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s