Why can I access private variables in the copy constructor?

前端 未结 5 922
梦谈多话
梦谈多话 2020-11-29 16:27

I have learned that I can never access a private variable, only with a get-function in the class. But then why can I access it in the copy constructor?

Example:

5条回答
  •  醉话见心
    2020-11-29 16:32

    You can access private members of a class from within the class, even those of another instance.

提交回复
热议问题