运行 ❯
获得您
自己的
网站
×
更改方向
更改主题、深色/浅色
进入空间
#include <iostream> #include <string> using namespace std; class Car { public: string brand; string model; int year; }; int main() { Car carObj1; carObj1.brand = "BMW"; carObj1.model = "X5"; carObj1.year = 1999; Car carObj2; carObj2.brand = "Ford"; carObj2.model = "Mustang"; carObj2.year = 1969; cout << carObj1.brand << " " << carObj1.model << " " << carObj1.year << "\n"; cout << carObj2.brand << " " << carObj2.model << " " << carObj2.year << "\n"; return 0; }
宝马 X5 1999
福特野马 1969