

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is difference between a pointer and reference parameter in C++?
Pointers
Pointer variables are used to store the address of variable.
Syntax
Type *pointer;
Initialization
Type *pointer; Pointer=variable name;
References
When a parameter is declared as reference, it becomes an alternative name for an existing parameter.
Syntax
Type &newname=existing name;
Initialization
Type &pointer; Pointer=variable name;
The main differences between pointers and reference parameters are −
References are used to refer an existing variable in another name whereas pointers are used to store address of variable.
References cannot have a null value assigned but pointer can.
A reference variable can be referenced by pass by value whereas a pointer can be referenced by pass by reference.
A reference must be initialized on declaration while it is not necessary in case of pointer.
A reference shares the same memory address with the original variable but also takes up some space on the stack whereas a pointer has its own memory address and size on the stack.
- Related Questions & Answers
- Difference Between Pointer and Reference
- What is the difference between object and reference in java?
- Difference Between Array and Pointer
- What are the differences between a pointer variable and a reference variable in C++?
- In C++ What are the differences between a pointer variable and a reference variable?
- Difference between pointer and array in C
- What is a reference/ref parameter of an array type in C#?
- Explain reference and pointer in C programming?
- What is the difference between pass by value and reference parameters in C#?
- Difference between OSI and TCP/IP Reference Model
- Difference between Call by Value and Call by Reference
- What is the difference between a++ and ++a in JavaScript?
- What is the difference between a simile and a metaphor?
- What is the difference between a method and a function?
- What is a final parameter in java?