Write a program for Private Member Function for each task

/* Private Member Function for each task  */
#include<iostream>
using namespace std;

class Rectangle
{
    int l,b;
    void area()
    {
       cout<<"\n\n Area:"<<l*b;
    }

    void peri()
    {
       cout<<"\n\n Perimeter: "<<2*(l+b);
    }

    public:
            void accept()
            {
                cout<<"\n\n Enter length and breadth: ";
                cin>>l>>b;

                area();
                peri();
            }
 };

int main()
{
   Rectangle r;

   r.accept();

   return 0;
}

Previous
Next Post »