A CLASS CIRCLE STORES AS A DATA MEMBER THE RADIUS AND AREA OF CIRCLE AND TWO CONSTRUCTOR FUNCTIONS. THE FIRST ACCEPTS ARGUMENT AS TH RADIUS AND CALCULATE ITS AREA. THE SECOND IS A COPY CONSTRUCTOR THAT INCREASES THE AREA OF CIRCLE BY 1 AND CALCULATE ITS AREA. ALSO, INCLUDE ANOTHER MEMBER FUNCTION TO DISPLAY RADIUS AND AREA OF THE CIRCLE.

#include<iostream.h>
#include<conio.h>
class circle
{
      float area,radius;
      public:
      circle(float rad)
      {
               radius=rad;
               area=3.14*radius*radius;
       }
       circle(circle & c)
       {
                radius=c.radius;
                area=c.area;
       }
       void display ()
       {
                cout<<”Radius:”<<radius;
                cout<<”Area:”<<area;
       }
};
void main()
{
        clrscr();
        circle ob(4.0);
        circle ob1(ob);
        ob.display();
        getch();
}

           

Comments

Post a Comment

Popular Posts