Home Segments Index Top Previous Next

414: Mainline

Note that, when you define a pointer variable in your program, the C++ compiler allocates only the small amount of memory required to hold an address. Then, later on, you can arrange for that address to be the address of a chunk of memory that is allocated for an object at run time.

cylinder c;     // Allocate space for a cylinder; 
                // in the implementation on which the programs 
                // in this book were tested, the space allocated 
                // happens to be 16 bytes for a basic definition 
                // in which there are two member variables, 
                // of type double, in the cylinder class 
cylinder *cptr; // Allocate space for a pointer to a cylinder; 
                // in the implementation on which the programs 
                // in this book were tested, the space allocated 
                // happens to be 4 bytes, no matter what the 
                // nature of the definition of the cylinder class