C++ - Pointers
#include "iostream.h"
// This program illustrates simple use of pointers
main()
{
int *pt_int;
float *pt_float;
int cat = 7, dog = 27;
float x = 1.2345, y = 32.14;
pt_int = &cat;
*pt_int += dog;
cout << "Cat now has the value of " << *pt_int << "\n";
pt_float = &x;
y += 5 * (*pt_float);
cout << "y now has the value of " << y << "\n";
const char *name1 = "John"; // Value cannot be changed
char *const name2 = "John"; // Pointer cannot be changed
}
// Result of execution
//
// Cat now has the value of 34
// y now has the value of 38.3125