Accessing of the Variables pointed to by the Pointer

Accessing of the variable pointed to by the pointer needs to be understood from two angles, i.e., Accessing of normal basic data-type variables Accessing of class-type objects Accessing of normal basic data-type variables: Let us straight-away learn the accessing of normal basic data-type (line int, float, etc.) variables by seeing a simple example as follows: int *p; int x; x = 20; p = &x; //read as assign address of x (&x) to pointer variable p cout << *p; //read as print content at pointer variable p The statement: cout << *p; prints the value 20 because *p means the value at the address p. Similarly: *p = *p + 10 is same as: x = x + 10; Note that if we write the following statement: cout << p; this prints the address of x. Similarly the statement: cout << &x; also prints the addresss of x. Accessing the...