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

  1. // ex07004.cpp
  2. // A class with two constructors
  3. #include <iostream.h>
  4.  
  5. // ------------ a Cube class
  6. class Cube    {
  7.     int height, width, depth;     // private data members
  8. public:
  9.      // ------ constructor functions
  10.     Cube() { /* does nothing */ }
  11.     Cube(int ht, int wd, int dp)
  12.         { height = ht; width = wd; depth = dp; }
  13.     // ----- member function
  14.     int volume() { return height * width * depth; }
  15. };
  16.  
  17. main()
  18. {
  19.     Cube thiscube(7, 8, 9);     // declare a Cube
  20.     Cube othercube;             // a Cube with no initializers
  21.     othercube = thiscube;
  22.     cout << othercube.volume();
  23. }
  24.