why private value of the obj can be changed by class instance?

前端 未结 2 1839
长情又很酷
长情又很酷 2020-12-11 09:58
#include
using namespace std;

class A
{
    private:
        int value;
    public:
        A(int init):value(init){}
        void changevalue(A &am         


        
2条回答
  •  天命终不由人
    2020-12-11 10:24

    Because class access specifier apply on per class basis and not per object basis.

    You can always modify the same type of object inside the class functions.Usual examples are copy constructor and copy assignment operator.

提交回复
热议问题