{public:
Point(double i, double j) { x=i; y=j; }
double Area() const { return 0.0; }
private:
double x, y;
};class Rectangle:public Point
{public:
Rectangle(double i, double j, double k, double l);
double Area() const { return w*h; }
private:
double w, h;
};Rectangle::Rectangle(double i, double j, double k, double l):Point(i, j)
{w=k; h=l;
}void fun(Point
fun(rec);
}该程序的运行结果为:
输出结果说明在fun()函数中,s所引用的对象执行的Area()操作被关联到Point::Area()的实现代码上。这是由于静态联编的结果。在程序编译阶段,对s所引用的对象所执行的Area()操作只能束定到Point类的函数上。因此,导致程 ...
附件列表