河南成教 / C++程序设计
5[完成题]
5[完成题]
在下面程序中的横线处填上适当内容,使程序完整。
# include
class vehicle
{
protected:
int size;
int speed;
public;
void setSpeed(int s){speed=s;}
virtual int getSpeedLevel( ){return speed/10;}
};
class car:public vehicle
{
public:
int getSpeedLeve( ){return speed/5;}
};
class truck:public vehicle
{
public:
int getspeedLevel( ){return speed/15;}
};
int maxSpeedLevel(vehicle &v1 ,vehicle )
{
if(v1.getSpeedLevel( )>v2.getSpeedLevel( ))
return 1;
else
reutrn 2;
}
void main()
{
turck t;
car c;
t.setSpeed(130);
c.setSpeed(60);
cout<<>
}
参考答案:
佳题速递: