The C++ Data Types
are defined using: type_name * object_name; // object_name is a pointer type
// object which can be used to point to objects of the particular type
int *pi; // data object pi is a pointer to an integer
char **pc; // pc is a pointer to a pointer to a character
float *v[10]; // v is an array of 10 pointers to float type objects
int (*fp)(char, char*); // fp can be used to point to any function which
// takes two arguments of type char, and char*, and returns a data value of type int
int* pi, I=10; // Watch out, I is only an integer, pi is a pointer to an integer
pi = & I; // pi now points to I. & is called the address of operator
The above is the same as: int I=10, *pi=&I; // here pi is declared and initialized
Objects can be referenced by their pointers as follows:
*pi = I + 100; // same as I = I + 100;
// *pi refers to object I which pi points to