1.

Can a function, other than the enclosing function of local class, access the class members?(a) Yes, using object(b) Yes, using direct call(c) Yes, using pointer(d) No, can’t accessI had been asked this question during an interview.Asked question is from Local Class topic in division Class Members & Types of Object Oriented Programming

Answer» CORRECT ANSWER is (d) No, can’t ACCESS

Explanation: The local classes are local to the specific enclosing function. Other functions can’t access the class. EVEN if the pointers are USED, the class must be alive when the pointer is used. But this will not happen if the enclosing function is returned.


Discussion

No Comment Found

Related InterviewSolutions