/* program to find area of rectangle using constructor*/
#include <iostream>
using namespace std;
class CRectArea{
    private:
    int length;
    int breadth;
    public:
    CRectArea (int,int);
    int areaofrect()
    {
        return (length * breadth);
        
    }
    int length1()
    {
        return length;
        
    }
    int breadth1()
    {
        return breadth;
    }
    
};
CRectArea::CRectArea(int x, int y )
{
    length = x;
    breadth = y;
}

int main() {
    CRectArea myrectangle (8,5);
    cout<<"the length of rectangle ::"<<myrectangle.length1()<<"\n";
    cout<<"\n the breadth of rectangle ::"<<myrectangle.breadth1()<<"\n";
    cout<<"\n the area of rectangle is :: "<< myrectangle.areaofrect()<<endl;
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: