问题 填空题

下列程序的执行结果为________。
#include<iostream.h>
class Point

public:
Point(double i,double j)x=i;y=j;
double Area( )constreturn 0.0;
private:
double x,y;
;
class Rectangle:public Point

public:
Rectangle(double i,double J,double k,double 1);
double Area( )const(return w*h;
private:
double w,h;
;
Rectangle::Rectangle(double i,double j,double k,double 1):Point(i,j)

w=k;h=l;

void fun(Point&s)

cout<<s.Area( )<<endl;

void main( )

Rectangle rec(3.0,5.2,15.0,25.0);
fun(rec);

答案

参考答案:0

解析: 注意本题不同于基类的指针指向派生类对象。Fun函数的形参是Point基类的引用。本题调用的是Point类对象的面积函数,其值永远为0。

多项选择题
单项选择题