菜单
  • 字节-豆包AI
  • 阿里-通义AI
  • 讯飞-星火AI
  • 百度-文心AI
  • GPT-代码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 | 酷代码 | 373字解答]

相关提问