1个回答
展开全部
#include <iostream>
using namespace std;
#define PI 3.14
class Point
{
public:
Point() : m_x(0), m_y(0){}
Point(double x, double y) : m_x(x), m_y(y){}
~Point(){}
protected:
double m_x;
double m_y;
};
class Rectangle : public Point
{
public:
Rectangle() : Point(){}
Rectangle(double x, double y) : Point(x, y){}
~Rectangle(){}
double Area()
{
return m_x * m_y;
}
};
class Circle : public Point
{
public:
Circle() : m_r(0){}
Circle(double r) : m_r(r){}
~Circle(){}
double Area()
{
return PI * m_r * m_r;
}
private:
double m_r;
};
int main()
{
Rectangle rect(3.2, 2.1);
Circle circle(5.1);
cout << "rect area : " << rect.Area() << endl;
cout << "circle area : " << circle.Area() << endl;
return 0;
}
using namespace std;
#define PI 3.14
class Point
{
public:
Point() : m_x(0), m_y(0){}
Point(double x, double y) : m_x(x), m_y(y){}
~Point(){}
protected:
double m_x;
double m_y;
};
class Rectangle : public Point
{
public:
Rectangle() : Point(){}
Rectangle(double x, double y) : Point(x, y){}
~Rectangle(){}
double Area()
{
return m_x * m_y;
}
};
class Circle : public Point
{
public:
Circle() : m_r(0){}
Circle(double r) : m_r(r){}
~Circle(){}
double Area()
{
return PI * m_r * m_r;
}
private:
double m_r;
};
int main()
{
Rectangle rect(3.2, 2.1);
Circle circle(5.1);
cout << "rect area : " << rect.Area() << endl;
cout << "circle area : " << circle.Area() << endl;
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询