美国电影坏女孩网盘:C++题目~~急

来源:百度文库 编辑:中科新闻网 时间:2024/05/08 20:00:05
求解运行结果
#include <iostream.h>
class point
{ public:
point(int x1,int y1) {x=x1;y=y1;}
int area() const {return 0;}
private:
int x,y;
};
class Rect:public point
{public:
Rect(int x1,int y1,int u1,int w1):point(x1,y1)
{ u=u1;w=w1;}
int area() const {return u*w;}
private:
int u,w;
};
void fun(point &p)
{cout<<p.area()<<endl;
}
void main()
{ Rect rec(2,4,10,6);
fun (rec);
}

我在VC里运行了一下,结果为0。

0

0