1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include<iostream>
using namespace std;
class Rectangle {
public:
Rectangle (double,double);
Rectangle (double,double,double,double);
bool check_square(double, double);
void show_check_sqaure_result(bool);
private:
double x,y;
double length,width;
};
class Circle {
public:
Circle (Rectangle);
};
Rectangle::Rectangle(double l,double w)
{
length = l;
width = w;
cout<<"The area is "<<length*width<<" unit sqaure."<<endl;
check_square(l,w);
}
Rectangle::Rectangle(double x0,double y0,double x1, double y1)
{
double a = (x1>x0) ? (x1-x0):(x0-x1);
double b = (y1>y0) ? (y1-y0):(y0-y1);
cout<<"The area is "<<a*b<<" unit sqaure."<<endl;
check_square(a,b);
}
bool Rectangle::check_square(double a, double b)
{
double c;
c = a-b;
show_check_sqaure_result(c);
}
void Rectangle::show_check_sqaure_result(bool k)
{
if (k==0)
cout<<"It is a square.";
else
cout<<"It is NOT a square.";
cout<<endl;
}
Circle::Circle(Rectangle)
{
cout<<"The area of respective circle is"<<endl;
}
int main()
{
Rectangle A(4.6,10, 3, 9);
Circle B(A);
Rectangle C(1,1);
Circle D(C);
system("pause");
}
|