//默认成员权限是private
class Person {
//private:
int age;
void run() {
cout << "Person::runm()" << endl;
}
};
//默认成员权限是public
struct Son {
//public:
int age;
void run() {
cout << "Person::runm()" << age <<endl;
}
};
int main(){
//利用类创建对象
Person person;
person.age=10;//报错
Son son;
son.age=10;//正常
getchar();
return 0;
}
总结:默认访问权限不一致,汇编代码都是一致的
原文:https://www.cnblogs.com/antake/p/13356156.html