HOME

Wednesday, October 7, 2015

SAMPLE PROGRAM FOR CONCEPT OF CONSTRUCTOR IN C++

#include<iostream>
#include<iomanip>
using namespace std;
class sample
{
    int l,b;
public:
    sample()
    {
        l=5;
        b=3;
    }
    void area()
    {
        int result=l*b;
        cout<<"Area of rectangle is"<<setw(15)<<result<<endl;
    }
};
int main()
{
    sample s;
    s.area();
    return 0;
}

No comments:

Post a Comment