#include <iostream>
using namespace std;
class Car{
public://成员数据string color; //颜色string brand; //品牌string type; //车型int year; //年限//其实也是成员数据,指针变量,指向函数的变量,并非真正的成员函数void (*printCarInfo)(string color,string brand,string type,int year);void (*CarRun)(string type);void (*CarStop)(string type);//真正的成员函数void realPrintCarInfo(); //声明成员函数
};//"::" 类或者命名空间的解析符
void Car::realPrintCarInfo() //在类的外部进行成员函数的实现
{string str = "车的品牌" + brand+ ",型号是" + type+ ",颜色是" + color+ ",上市年限是" + std::to_string(year);cout << str<<endl;
}int main()
{cout << "Hello World!" << endl;Car BMW3;BMW3.color = "白色";BMW3.brand = "宝马";BMW3.type = "跑车";BMW3.year = 2010;//Car AodiA6 = new Car();BMW3.realPrintCarInfo();return 0;
}