📄 8-5.h
字号:
#define PI 3.14
class Shape
{
public:
float virtual GetArea()=0;
float virtual GetPerim()=0;
};
class Rectangle:public Shape
{
private:
float l,w;
public:
Rectangle(float l=0,float w=0);
float GetArea();
float GetPerim();
};
Rectangle::Rectangle(float l, float w)
{
this->l=l;
this->w=w;
}
float Rectangle::GetArea()
{
return l*w;
}
float Rectangle::GetPerim()
{
return 2*(l+w);
}
class Circle:public Shape
{
private:
float r;
public:
Circle(float r=0);
float GetArea();
float GetPerim();
};
Circle::Circle(float r)
{
this->r=r;
}
float Circle::GetArea()
{
return r*r*PI;
}
float Circle::GetPerim()
{
return 2*PI*r;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -