//
//   A class hierarchy of different types of figures.  It will be used
//   to demonstrate virtual functions and polymorphism.
//
 
#ifndef Figure_h_
#define Figure_h_

//  "Figure" is now an abstract base class. 

class Figure {
public:
	Figure() {}
	void Output_Info( );
	float Area( ) { return 0.0; }   // defaults to 0.0 if not redefined
	float Volume( ) { return 0.0; } // defaults to 0.0 if not redefined
};


//
//  "Rectangle" is  derived class of "Figure".  Note that it does not
//  redefine the "Volume" member function because rectangles have 0
//  volume.
//
class Rectangle : public Figure {
public:
	Rectangle( float height_in, float width_in );
	void Output_Info( );
	float Area( );
protected:
	float height, width;
};


//
//  "Square" is derived class of "Rectangle".  It has neither its own
//  variables nor its own Area function.  These are inherited from
//  Rectangle.  The constructor ensures that the height and width are
//  the same.
//
class Square : public Rectangle {
public:
	 Square( float side );
	 void Output_Info( );
};


//
//  "Circle" is  derived class of "Figure".  Note that it does not
//  redefine the "Volume" member function because circles have 0
//  volume.
//
class Circle : public Figure {
public:
	 Circle( float radius_in );
	 void Output_Info( );
	 float Area( );

protected:
	 float radius;
};
  

//
//  "Sphere" is  derived class of "Figure".  It redefines both the
//  "Area" (surface area) and "Volume" member functions.
//
class Sphere : public Figure {
public:
	Sphere( float radius_in );
	void Output_Info( );
	float Area( );
	float Volume( );
private:
	float radius;
};

#endif
  
