For a C++ program, computer memory is like succession memory cells, each holding one-byte size and having a unique address. Dealing with these memory addresses in programming is done by pointers. Pointers are extremely powerful programming tool that can make things easier and help to increase the efficiency of a program and allow programmers to handle an unlimited amount of data. It is possible for pointers to dynamically allocate memory, where programmers don't have to worry about how much memory they will need to assign for each task, which cannot be done/performed without the concept of a pointer. Hence pointer is considered as the most distinct and exciting feature of C++ language which adds power as well as flexibility to the language. In other words, a pointer variable holds the address of a memory location.

Pointer Definition in C++

type *variable_name;
int  *height;
char  *age;

Benefits of using Pointers in C++

  • Pointers save the memory.
  • Pointers reduce the length and complexity of a program.
  • Pointers allow passing of arrays and strings to functions more efficiently.
  • Pointers make possible to return more than one value from the function.
  • Pointers increase the processing speed.

How to use Pointers in C++

#include <iostream>
using namespace std;

int main ()
   int  n = 20, *ptr;  /* actual and pointer variable declaration */

   ptr = &n;  /* store address of n in pointer variable*/
   cout << "Address of n variable: " << &n << endl;
   /* print address stored in pointer variable */
   cout << "Address stored in pntr variable: " << ptr << endl;

   /* print access the value using the pointer */
   cout << "Value of *pntr variable: " << *ptr << endl;
   return 0;
Program Output: