C++ examples for Data Type:Pointer
Pointers as address variables
#include <iostream> using namespace std; int main()// w ww.j av a2 s .com { int var1 = 11; int var2 = 22; cout << &var1 << endl //print addresses of variables << &var2 << endl << endl; int* ptr; //pointer to integers ptr = &var1; //pointer points to var1 cout << ptr << endl; //print pointer value ptr = &var2; //pointer points to var2 cout << ptr << endl; //print pointer value return 0; }