A member function can always access the data
A member function can access its class member variables, irrespective of the access specifier in which the member variable is declared. So, a member function can always access the data in the class of which it is a member.
Functionswithin classes can access and modify data members without declaring them, because the data members are already declared in the class.
A member function of a class is a function that has its definition or its prototype within the class definition like any other variable. It operates on any object of the class of which it is a member, and has access to all the members of a class for that object.