home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////
- // Program Name: Rect.CPP
- /////////////////////////
-
-
- ////////////
- // #include
- ////////////
- #include <iostream.h>
-
-
- ////////////////////////////////////
- // The CRectangle class declaration
- ////////////////////////////////////
- class CRectangle
- {
- public:
- CRectangle(int w, int h); // Constructor
-
- void DisplayArea (void); // Member function
-
- ~CRectangle(); // Destructor
-
- int m_Width; // Data member
- int m_Height; // Data member
-
- };
-
-
- ////////////////////////////
- // The constructor function
- ////////////////////////////
- CRectangle::CRectangle( int w, int h)
- {
-
- m_Width = w;
- m_Height = h;
-
- }
-
-
- ////////////////////////////
- // The destructor function
- ////////////////////////////
- CRectangle::~CRectangle()
- {
-
-
-
- }
-
-
- ////////////////////////////////
- // Function Name: DisplayArea()
- ////////////////////////////////
- void CRectangle::DisplayArea(void)
- {
-
- int iArea;
-
- iArea = m_Width * m_Height;
-
- cout << "The area is: " << iArea << "\n";
-
- }
-
- void main(void)
- {
-
- CRectangle MyRectangle ( 10, 5 );
-
- MyRectangle.DisplayArea();
-
-
- }
-