运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 Spaces
#include <iostream> #include <string> using namespace std; // Base class class Vehicle { public: string brand = "Ford"; void honk() { cout << "Tuut, tuut! \n" ; } }; // Derived class class Car: public Vehicle { public: string model = "Mustang"; }; int main() { Car myCar; myCar.honk(); cout << myCar.brand + " " + myCar.model; return 0; }
鸣笛声,鸣笛声!
福特野马