#include#include#includeusing namespace::std;
class Vehicle
{
public:
Vehicle();
int weight;
Vehicle(int WEIGHT) {
weight = WEIGHT;
};
void setWeight(int);
};
void Vehicle::setWeight(int WEIGHT)
{
weight = WEIGHT;
}
Vehicle::Vehicle(){}
class Car :virtual public Vehicle
{
public:
Car();
int aird;
Car(int WEIGHT, int AIRD) :Vehicle(WEIGHT) {
aird = AIRD;
};
void setAird(int);
};
Car::Car(){}
void Car::setAird(int AIRD)
{
aird = AIRD;
}
class Boat:virtual public Vehicle
{
public:
Boat();
double tonnage;
Boat(int WEIGHT, double TONNAGE) :Vehicle(WEIGHT) { tonnage = TONNAGE; };
void setTonnage(double);
};
Boat::Boat() {}
void Boat::setTonnage(double TONNAGE)
{
tonnage = TONNAGE;
}
class AmphibianCar :public Car, public Boat
{
public:
AmphibianCar();
AmphibianCar(int WEIGHT, int AIRD, double TONNAGE) :Vehicle(WEIGHT), Car(WEIGHT, AIRD), Boat(WEIGHT, TONNAGE) {};
void display1() {
cout<< "init Vehicle"<< endl;
cout<< "init car"<< endl;
cout<< "init Boat"<>WEIGHT >>AIRD >>TONNAGE;
cin >>WEIGHT1 >>AIRD1 >>TONNAGE1;
AmphibianCar Car1(WEIGHT, AIRD, TONNAGE);
Car1.display1();
Car1.setWeight(WEIGHT1);
Car1.setAird(AIRD1);
Car1.setTonnage(TONNAGE1);
Car1.display2();
return 0;
}
學(xué)院的題目,感覺還是挺簡(jiǎn)單的,但總感覺我的實(shí)現(xiàn)思路不像是學(xué)院要求的思路。大概跟上一題差不太多,但是我不懂輸出reset是為了干什么。題目是水陸兩用汽車類。
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧