主题:急救
下面程序的执行结果是( )
#i nclude<iostream>
class point
{
int x,y;
public:
point(int x1,int y1)
{
x=x1;
y=y1;
}
virtual int area() const
{
return 0;
}
};
class Rect:public point
{
int l,w;
public:
Rect(int x1,int y1,int l1,int w1):point(x1,y1)
{
l=l1;
w=w1;
}
virtual int area() const
{
return 1*w;
}
};
void fun(point &p)
{
cout<<p.area()<<endl;
}
void main()
{
Rect rec(1,2,3,4);
fun(rec);
}
#i nclude<iostream>
class point
{
int x,y;
public:
point(int x1,int y1)
{
x=x1;
y=y1;
}
virtual int area() const
{
return 0;
}
};
class Rect:public point
{
int l,w;
public:
Rect(int x1,int y1,int l1,int w1):point(x1,y1)
{
l=l1;
w=w1;
}
virtual int area() const
{
return 1*w;
}
};
void fun(point &p)
{
cout<<p.area()<<endl;
}
void main()
{
Rect rec(1,2,3,4);
fun(rec);
}