/*
Multiple Inheritance
AREA PERIMETER
RECTANGLE
*/
#include<iostream>
using namespace std;
class Area
{
public:
void area(int length,int breadth)
{
int a;
a=length*breadth;
cout<<"\n\n Area: "<<a;
}
};
class Perimeter
{
public:
void perimeter(int length,int breadth)
{
int per;
per=2*(length+breadth);
cout<<"\n\n Perimeter: "<<per;
}
};
class Rectangle: public Perimeter,public Area
{
int length,breadth;
public:
void get_data()
{
cout<<"\n\n Enter length and breadth: ";
cin>>length>>breadth;
}
void display()
{
Perimeter::perimeter(length,breadth);
Area::area(length,breadth);
}
};
int main()
{
Rectangle r;
r.get_data();
r.display();
return 0;
}
Multiple Inheritance
AREA PERIMETER
RECTANGLE
*/
#include<iostream>
using namespace std;
class Area
{
public:
void area(int length,int breadth)
{
int a;
a=length*breadth;
cout<<"\n\n Area: "<<a;
}
};
class Perimeter
{
public:
void perimeter(int length,int breadth)
{
int per;
per=2*(length+breadth);
cout<<"\n\n Perimeter: "<<per;
}
};
class Rectangle: public Perimeter,public Area
{
int length,breadth;
public:
void get_data()
{
cout<<"\n\n Enter length and breadth: ";
cin>>length>>breadth;
}
void display()
{
Perimeter::perimeter(length,breadth);
Area::area(length,breadth);
}
};
int main()
{
Rectangle r;
r.get_data();
r.display();
return 0;
}