Home Segments Index Top Previous Next

233: Mainline

The cylinder class, like the box class, is derived from the container class:

const double pi = 3.14159;
class cylinder : public container {  
  public: double radius, length; 
          // Default constructor: 
          cylinder ( ) { } 
          // Other member function: 
          double volume ( ) {return pi * radius * radius * length;} 
}; 

Note that the cylinder class now contains the member variables and the member function formerly found in the tank_car class.