//11/26 作业(5)
#include
using namespace std;
const double PI=3.14159;
class Shape
{
protected:
int x,y;
public:
//void set(int x1,int y1=0){x=x1; y=y1;}
//Shape(int x1,int y1=0){x=x1; y=y1;}
virtual double GetArea()=0;
virtual double GetPerim()=0;
};
class Rectangle:public Shape
{
public:
Rectangle(int x1,int y1=0){x=x1; y=y1;}
double GetArea(){cout<<"The area of rectangle is: "<
//11/26 作业(5)
最新推荐文章于 2025-09-16 16:06:10 发布
博客展示了一段作业代码,定义了抽象基类Shape,包含纯虚函数GetArea和GetPerim,还定义了派生类Rectangle继承自Shape,实现了相关函数,最后进行了对象的创建和函数调用。
923

被折叠的 条评论
为什么被折叠?



