Accessing private member variables of a class from a static method

I am able to access the private member variable of the class shown in below code directly using an object instance (pointer to object). As per my understanding private members should not be accessible. Can someone please help to explain the reason behind this behaviour ? #include <iostream> class myClass; using myClassPtr = std::shared_ptr<myClass>; class… Read More Accessing private member variables of a class from a static method