//********************************************************************
//
File: circle .h
//
Definition for the class circle
//********************************************************************
#ifndef CIRCLE_H
#define CIRCLE_H
#include "figure.h"
class circle : public figure // a circle is a figure
{
// Overriding member
functions (unique for circles)
public:
// Read a circle
void
readFigure ( ) ;
// Compute the area of a circle
void
computeArea ( ) ;
// Compute the perimeter of a circle
void
computePerim( );
// Display characteristics unique to circle s
void
displayFig( );
// Data members (unique to circles) . . .
private:
float
radius;
};
#endif // CIRCLE_H
//*********************************************************************
//
File: circle.cpp
//
Implementation of the class circle
//********************************************************************
#include <iostream>
using namespace std;
#include "circle.h"
const float pi = 3.1415927;
//
Read data unique to a circle
void circle::readFigure( )
{ cout << "Enter radius
: ";
cin >> radius;
}
//
Compute the perimeter (circumference) of a circle
void circle::computePerim( )
{ perimeter = 2.0 * pi * radius;
}
//
Compute the area of a circle
void circle:: computeArea ( )
{ area = pi * radius * radius;
}
//
Display the characteristics of a circle
void circle::displayFig( )
{
// Display the
type of figure and its radius.
cout << "Figure
Shape is Circle"<< endl;
cout << "Radius
is " << radius << endl;
// Call the
corresponding function
// in the base
cass to display the commoncharacteristics.
figure::displayFig();
}