next up previous contents
Next: Structs Up: Some basics of object-oriented Previous: Compilation of programs under   Contents

Pointers

At first, one typically does things such as


{}
int id = 1 ;
double xCoord = 2.34 ;
cout << id << endl ;
cout << xCoord << endl ;
Pointers allow to put the real stuff somewhere else and to reference it by an address:


{}
int* id ; *id = 1 ;
double* xCoord ; *xCoord = 2.34 ;
cout << *id << endl ;
cout << *xCoord << endl;

What this means is that id itself contains just a memory address, and the real content is where this memory address points to. *(...) can thus be read as ``contents of (...)''.

This does not have any advantage at this level; but it has enormous advantages as soon as the content that the memory address points to is more than a simple number.



2004-02-02