Using Pointers in C++ - C++ Data Type

C++ examples for Data Type:Pointer

Description

Using Pointers in C++

Demo Code

#include <iostream> 
  
using namespace std; 
  
int main(int argc, char *argv [])
{ 
        int     variable = 5; 
        int*    variablePointer = &variable; 
  
        cout << "Value of variable: " << variable << endl; 
  
        cout << "Address of variable: " << &variable << endl; 
  
        cout << "Value of variablePointer: " << variablePointer << endl; 
  
        cout << "Value of variablePointer + 1: " << variablePointer + 1 << endl; 
  
        cout << "Value of memory at dereferenced variablePointer: " << *variablePointer << endl; 
  
        cout << "Value of memory at dereferenced variablePointer + 1: " << *variablePointer + 1 << endl; 
  
        return 0; 
}

Result


Related Tutorials