C++ Programming Code Examples C++ > Pointers Code Examples Pointer Simple with Reference operator (&) and Dereference operator (*) Pointer Simple with Reference operator (&) and Dereference operator (*) The pointer is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address. Reference operator ("&") The reference operator noted by ampersand ("&"), is also a unary operator in c languages that uses for assign address of the variables. It returns the pointer address of the variable. This is called "referencing" operater. Dereference operator ("*") The dereference operator or indirection operator, noted by asterisk ("*"), is also a unary operator in c languages that uses for pointer variables. It operates on a pointer variable, and returns l-value equivalent to the value at the pointer address. This is called "dereferencing" the pointer. // Header Files #include <iostream> #include<conio.h> using namespace std; int main() { //Pointer Variable Declaration for Integer Data Type int* pt; int var; cout << "C++ Pointer Example for Reference operator (&) and Dereference operator (*)\n"; var = 1; cout << "Address of var :" << &var << "\n"; cout << "Value of var :" << var << "\n\n"; //& takes the address of var , Here now pt == &var, so *pt == var pt = &var; cout << "Address of Pointer pt :" << pt << "\n"; cout << "Content of Pointer pt :" << *pt << "\n\n"; var = 2; cout << "Address of Pointer pt :" << pt << "\n"; cout << "Content of Pointer pt :" << *pt << "\n\n"; //Assign Values using dereference operator *pt = 3; cout << "Address of var :" << &var << "\n"; cout << "Value of var :" << var << "\n\n"; getch(); return 0; }