1.

If private members have to be accessed directly from outside the class but the access specifier must not be changed, what should be done?(a) Specifier must be changed(b) Friend function should be used(c) Other public members should be used(d) It is not possibleThe question was asked by my school principal while I was bunking the class.This is a very interesting question from Private Access Specifier topic in section Access Specifiers of Object Oriented Programming

Answer»

Correct answer is (b) Friend function should be used

The best explanation: For calling the function DIRECTLY, we can’t USE another function because that will be indirect CALL. USING friend function, we can access the private MEMBERS directly.



Discussion

No Comment Found

Related InterviewSolutions