访问同一类中另一个对象的私有字段
class Person
{
private BankAccount account;
Person(BankAccount account)
{
this.account = account;
}
public Person someMethod(Person person)
{
//Why accessing private field is possible?
BankAccount a = person.account;
}
}
请忘记设计。我知道OOP指定私有对象是类的私有对象。我的问题是,为什么OOP被设计成私有字段具有类级访问权限而不是对象级访问权限?