home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / samples.z / Rect.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-30  |  1.2 KB  |  52 lines

  1. // "Inherited Constructors" - RECT.HPP
  2. #include <iostream.h>
  3.  
  4. class rectangle {
  5.   public:
  6.     rectangle( double h=1, double w=1 );
  7.     // default constructor
  8.  
  9.     virtual ~rectangle();
  10.  
  11.     // query and manipulation
  12.     //    member functions
  13.     virtual double getHeight()
  14.       {return height; };
  15.     virtual void   setHeight( double h)
  16.       {height=h; };
  17.  
  18.     virtual double getWidth()
  19.         {return width; };
  20.     virtual void   setWidth( double w)
  21.       {width=w; };
  22.  
  23.     virtual void   growBy( double h, double w );
  24.  
  25.     protected:
  26.       double height, width;           // internal data
  27. };
  28.  
  29. class square : public rectangle {
  30.   public:
  31.     // constructor:
  32.     square( double size = 1 );
  33.     // destructor:
  34.     virtual ~square();
  35.  
  36.     // Redefine member functions:
  37.       void   setHeight( double h)
  38.                 {height=h;width = h;  };
  39.       void   setWidth( double w)
  40.                 {width=w; height = w; };
  41.       void   growBy( double s, double = 0 );
  42.  
  43.     // New square member functions:
  44.       void   setSize( double s )
  45.                 {height=s; width = s; };
  46.       double getSize(  )
  47.                 { return height; };
  48.  
  49. };
  50.  
  51.  
  52.