next up previous contents
Next: The Standard Template Library Up: Some basics of object-oriented Previous: Constructors   Contents

Arrays of classes

Typically, we have more than one node. The straightforward way to do this would be


{}
...
Node* nodes[20] ; // allocate 20 memory addresses
...
nodes[0] = new Node ( ) ; // allocate space for ONE (!) node
...
nodes[0]->set_id( 213 ) ;
xx = nodes[0]->x() ;



2004-02-02