home *** CD-ROM | disk | FTP | other *** search
- // ex07002.cpp
- // The Cube class with inline functions
- #include <iostream.h>
-
- // ------------ a Cube class
- class Cube {
- int height, width, depth; // private data members
- public:
- // ------ inline constructor function
- Cube(int ht, int wd, int dp)
- { height = ht; width = wd; depth = dp; }
- // ----- inline member function
- int volume()
- { return height * width * depth; }
- };
-
- main()
- {
- Cube thiscube(7, 8, 9); // declare a Cube
- cout << thiscube.volume(); // compute & display volume
- }