Pointers in C++ :

Pointer Definition :

C language Pointer Definition, Declaration or Expressions - The variable that stores the address of another variable is what in C++ in called pointer. Pointer are a very powerful feature of the language that has many uses in lower level programming.

Benefits of using Pointers in C++ :

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

Example :

  1. /* Description: print 'a' address values step by step */
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int n=10, *ptr;
  7. ptr = &n;
  8. cout << "Address of n variable: " << &n << endl;
  9. cout << "Address stored in pntr variable: " << ptr << endl;
  10. cout << "Value of *pntr variable: " << *ptr << endl;
  11. }

Output :

C++ language print 'a' address values step by step

Next Update

Loading...

We have two YouTube channels their name is CodeX or NightHawk. CodeX is for programming related videos and NightHawk is for online game streaming so please supporting us and Subscribe to our channels