home *** CD-ROM | disk | FTP | other *** search
- // "Inherited Constructors" - RECT.HPP
- #include <iostream.h>
-
- class rectangle {
- public:
- rectangle( double h=1, double w=1 );
- // default constructor
-
- virtual ~rectangle();
-
- // query and manipulation
- // member functions
- virtual double getHeight()
- {return height; };
- virtual void setHeight( double h)
- {height=h; };
-
- virtual double getWidth()
- {return width; };
- virtual void setWidth( double w)
- {width=w; };
-
- virtual void growBy( double h, double w );
-
- protected:
- double height, width; // internal data
- };
-
- class square : public rectangle {
- public:
- // constructor:
- square( double size = 1 );
- // destructor:
- virtual ~square();
-
- // Redefine member functions:
- void setHeight( double h)
- {height=h;width = h; };
- void setWidth( double w)
- {width=w; height = w; };
- void growBy( double s, double = 0 );
-
- // New square member functions:
- void setSize( double s )
- {height=s; width = s; };
- double getSize( )
- { return height; };
-
- };
-
-
-