const成员:被const修饰的成员变量、非静态成员函数

const修饰成员变量

void test1() const { // 会报错
    // this->m_price = 10;
}
void test() {
    cout << "test()" << endl;
}

void test() const {
    cout << "test() const" << endl;
}
int main() {
	Car car;
	car.test();

	Car *p = new Car();
	p->test();

	const Car car2;
	car2.test();

	const Car *p2 = new Car();
	p2->test();
    
    getchar();
    return 0;
}