by Dinesh Thakur Category: Classes in C++

 

#include<iostream.h>

#include<conio.h>
class rectangle
{
     private:
     int m,n;
     public:
     void setdata(int,int);
     void area();
};
              void rectangle::setdata(int u,int v)
          {
                 m=u;
                 n=v;           
          }
               void rectangle::area()
         {
                int a=m*n;
                cout<<"\nArea of Rectangle= "<<a;
         }
               void main()
    {
                clrscr();
                rectangle f,s;
                f.setdata(10,20);
                cout<<"Rectangle First : ";
                f.area();
                s.setdata(20,30);
                cout<<"\nRectangle Second :";
                s.area();
                getch();
     }

Using Member Functions Outside The Body Of Class To Find Area Of Rectangle



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles