class Car {
public:
const int m_price = 0; //const常量设置
Car() :m_price(0) {} //也可以在构造函数中初始化
void run() const { //const一般写最后
cout << "run()" << endl;
m_price = 10;
}
};
void run() const {}
void run() {}
int age;
int & m_price = age;
car(int &price) :m_price(price) {}
//拷贝构造函数
Car(const Car &car) {
cout << "Car(const Car &car)" << endl;
}
Car car4(car3);
const成员-拷贝构造函数(copy constructor)
原文:https://www.cnblogs.com/sec875/p/12328947.html