home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////
- // Program Name: Circle.CPP
- /////////////////////////////
-
- ///////////////////
- // #include files
- ///////////////////
- #include <iostream.h>
-
- // Declare the Circle class
- class CCircle
- {
- public:
- CCircle( int r); // Constructor
- void SetRadius(int r);
- int GetRadius(void);
- void DisplayArea(void);
- ~CCircle(); // Destructor
- private:
- float CalculateArea(void);
- int m_Radius;
- int m_Color;
- };
-
-
- ///////////////////////////
- // The constructor function
- ///////////////////////////
- CCircle::CCircle ( int r )
- {
-
- // Set the radius
- m_Radius = r;
-
- }
-
-
- //////////////////////////
- // The destructor function
- //////////////////////////
- CCircle::~CCircle ()
- {
-
-
- }
-
-
- ///////////////////////////////
- // Function Name: DisplayArea()
- ///////////////////////////////
- void CCircle::DisplayArea ( void )
- {
-
- float fArea;
-
- fArea = CalculateArea ( );
-
- // Print the area
- cout << "The area of the circle is: " << fArea;
-
-
- }
-
-
- /////////////////////////////////
- // Function Name: CalculateArea()
- /////////////////////////////////
- float CCircle::CalculateArea ( void )
- {
-
- float f;
-
- f = (float) (3.14 * m_Radius * m_Radius);
-
- return f;
-
- }
-
-
- void main(void)
- {
- // Create an object of class Circle with
- // radius equals to 10.
- CCircle MyCircle ( 10 );
-
- // Display the area of the circle
- MyCircle.DisplayArea();
-
- }