1.

Can pointers to object access the private members of the class?(a) Yes, always(b) Yes, only if it is only pointer to object(c) No, because objects can be referenced from another objects too(d) No, neverI had been asked this question in homework.The query is from Pointer to Objects topic in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Correct choice is (d) No, never

Explanation: The POINTERS to an object can never access the private MEMBERS of the class OUTSIDE the class. The object can indirectly USE those private members using member FUNCTIONS which are public in the class.



Discussion

No Comment Found

Related InterviewSolutions