Answers for "what is difference between reference variable and pointer in c++"

C++
2

variable vs pointer in c++

// Variable is used to store value
int a = 5;
cout << a; //output is 5

// Pointer is used to store address of variable
int a = 5;
int *ab;
ab = &a; //& is used get address of the variable
cout << ab; // Output is address of variable
Posted by: Guest on May-27-2021
1

difference between pointer and reference in c++

Pointers: 
A pointer is a variable that holds memory address of another variable. 
A pointer needs to be dereferenced with * operator to access the 
memory location it points to. 

References :
 A reference variable is an alias, that is, 
another name for an already existing variable.
 A reference, like a pointer, is also implemented 
by storing the address of an object.
Posted by: Guest on May-14-2021

Code answers related to "what is difference between reference variable and pointer in c++"

Browse Popular Code Answers by Language