HOME

Wednesday, October 7, 2015

SAMPLE PROGRAM FOR PARAMETERIZED CONSTRUCTOR IN C++

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

No comments:

Post a Comment