Computer Science, asked by Nemichandchundawat, 1 year ago

1. describe the mechanism of accessing data member and member
functions in the following:-
a) inside the main program.
b) inside a member functio0n of the same class.
c) inside a member function of another class.

Answers

Answered by singhekamjot
1
Accessing a data member depends solely on the access control of that data member. If its public, then the data member can be easily accessed using the direct member access (.) operator with the object of that class.
If, the data member is defined as private or protected, then we cannot access the data variables directly. Then we will have to create special public member functions to access, use or initialize the private and protected data members. These member functions are also called Accessors and Mutator methods or getter and setter functions.

Nemichandchundawat: thanks, but answer in detail
Similar questions