酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

#include <iostream> #include<cstring> using namespace std; class vehicle{ public: void run(); string getname(); vehicle(string name); string name; }; vehicle::vehicle(string name){ this->name = name; } void vehicle::run(){ cout<<"出发"<<endl; } string vehicle::getname(){ return name; } class car:public vehicle{ public: void break(); void display(); car(int seats,string color,string type,int power,string name); en

car::car(int seats, string color, string type, int power, string name):vehicle(name){ this->seats = seats; this->color = color; this->type = type; this->power = power; } void car::break(){ cout<<"刹车"<<endl; } void car::display(){ cout<<"车名:" << getname()<<endl; cout<<"座位数:" <<seats<<endl; cout<<"颜色:" <<color<<endl; cout<<"类型:" <<type<<endl; cout<<"功率:" <<power<<endl; } int main(){ car c1(5,"Red","Sedan",200,"Honda Civic"); c1.display(); c1.run(); c1.break(); return 0; } [2024-05-26 17:02:18 | AI写代码神器 | 373点数解答]

相关提问