Write a program to demonstrate the use of a reference pointer.
#include<iostream> using namespace std; int main() { int a = 10; int *ptr = &a; int *rp = ptr; cout << "a = " << a << " &a = " << &a << endl; cout << "*ptr = " << *ptr << " ptr = " << ptr << endl; cout << "*rp = " << *rp << " rp = " <<rp << endl; return 0; }
Output
a = 10 &a = 0x28fef4 *ptr = 10 ptr = 0x28fef4 *rp = 10 rp = 0x28fef4