C++ examples for Data Type:Pointer
Using Pointers to Point to Something Else and Back Again
#include <iostream> using namespace std; int main() /* www .j a v a2 s . com*/ { int i; int j; int *ptrToComp; ptrToComp = &i; *ptrToComp = 2; cout << *ptrToComp << endl; ptrToComp = &j; *ptrToComp = 5; cout << *ptrToComp << endl; ptrToComp = &i; cout << *ptrToComp << endl; return 0; }