In class A, I defined a private member data char * d;.
And also in class A, I am overloading operator= that takes a const A &other parameter and do assignment.
At this time when I am overloading operator=, I realized that my Visual Studio C++ doesn’t give me an alert when I am trying to write something like d = *other.d.
So I am here to ask why I am allowed to do this? I haven’t run this program yet but just curious why I didn’t receive an alert for this line. In my mind private data members can only be accessed by getters.
So am I wrong?
Access restrictions operate by class, not by instance –
class Amethods can access private data for any instance of the class, not justthis.