#include
<iostream.h>
class
Shape{
( )//访问控制权限为保护类型
double x,y;
public:
Shape(double
i=0, double j=0) {
x=i;
y=j;
}
⑥ //将GetArea声明为纯虚函数
};
class
Rectangle: public Shape{//定义矩形类
public:
Rectangle(double a,double b):Shape(a,b)//派生类的构造函数。
{ }
double GetArea( ){
⑦
}
};
class
Square: public Rectangle{//定义正方形类
public:
⑧ //定义正方形的构造函数,注意x和y的大小
{ }
};
⑨ //定义圆类Circle,从形状类公用继承
public:
Circle(double r):Shape(r,0)
{ }
double GetArea( ){
return 3.14*x*x;
}
};
void
main( ){
Rectangle r(20,15);
Square s(15);
⑩ //创建一个圆对象c,其半径为10
cout<<"矩形的面积为: "<<r.GetArea( )<<endl;
cout<<"正方形的面积为: "<<s.GetArea( )<<endl;
cout<<"圆形的面积为: "<<c.GetArea( )<<endl;
那上面括号内的呢
追答protected: