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

Classes and minimal memory management

In C++, we can replace struct by class:


{}
class Node {
    int id ;
    double xCoord ;
    double yCoord ;
};
...
Node* node ; // reserve space for memory address
...
node = new Node() ; // reserve memory space for contents
...
node->id = 213 ; 
xx = node->xCoord ;
the use of new also solves the memory problem.4.1



2004-02-02