home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ANSICPP.ZIP / EX07002.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-24  |  516 b   |  22 lines

  1. // ex07002.cpp
  2. // The Cube class with inline functions
  3. #include <iostream.h>
  4.  
  5. // ------------ a Cube class
  6. class Cube    {
  7.     int height, width, depth;     // private data members
  8. public:
  9.      // ------ inline constructor function
  10.     Cube(int ht, int wd, int dp)
  11.         { height = ht; width = wd; depth = dp; }
  12.     // ----- inline member function
  13.     int volume() 
  14.         { return height * width * depth; }
  15. };
  16.  
  17. main()
  18. {
  19.     Cube thiscube(7, 8, 9);        // declare a Cube
  20.     cout << thiscube.volume();    // compute & display volume    
  21. }
  22.