注意:此页面搜索的是所有试题
[应用题,25分] #include
float const PI=3.14;
class point
{
private:
float x,y,area;
public:

point(float x1=0.0,float y1=0.0)
{
cout<<"point构造函数被调用!\n";
}

virtual ~point()
{
cout<<"point析构函数被调用!\n";}
virtual float getarea(){return 0.0;}
};

class circle:public point
{private:
float r;
public:
circle(float x1,float y1,float Nr):point(x1,y1)
{
r=Nr;
cout<<"circle构造函数被调用!\n ";
}
~circle(){cout<<"circle析构函数被调用!\n";}
float getarea()
{
return PI*r*r;
}
};
void main()
{
point *p,p1(3,4);
p=&p1;
cout<getarea()<
circle c(1,1,1);
p=&c;
cout<getarea()<<>
}
程序运行结果为:

参考答案