With a private modifier, why can the member in other objects be accessed directly?

前端 未结 4 1984
梦如初夏
梦如初夏 2020-11-28 08:13

I have the following code:

class A 
{
private:
    int x;
public:
    A()
    {
        x = 90;
    }
    A(A a1, A a2)
    {
        a1.x = 10;
        a2.x         


        
4条回答
  •  猫巷女王i
    2020-11-28 08:36

    Short answer: In member methods of class A, all the members of (object/pointer and static member) class A can be accessed.

提交回复
热议问题