Computer Science, asked by akshithaakkuanu26323, 4 months ago

using the concept of inheritance write a c++ program to calculate the area and perimeter of rectangle​

Answers

Answered by shalmaleeghosh806
0

I don't the answer sorry

Answered by ghodkeshubhangi34
2

Explanation:

#include <iostream.h>

#include<conio.h>

class Area

{

public:

float area(float l,float b)

{

return l*b;

}

};

class Perimeter

{

public:

float peri(float l,float b)

{

return 2*(l+b);

}

};

class Rectangle : private Area, private Perimeter

{

private:

float length, breadth;

public:

Rectangle() : length(0.0), breadth(0.0) { }

void get_data( )

{

cout<<"Enter length: ";

cin>>length;

cout<<"Enter breadth: ";

cin>>breadth;

}

};

int main()

{

Rectangle r;

r.get_data();

cout<<"Area = "<<r.area_calc();

cout<<"\nPerimeter = "<<r.peri_calc();

return 0;

}

Similar questions