What are friend member functions (C++)?

What are friend member functions (C++)?
A. Member function which can access all the members of a class
B. Member function which can modify any data of a class
C. Member function which doesn’t have access to private members
D. Non-member functions which have access to all the members (including private) of a class
 
Answer: d
Explanation: A non-member function of a class which can access even the private data of a class is a friend function. It is an exception on access to private members outside the class. It is sometimes considered as a member functions since it has all the access that a member function in general have.
 

Tìm kiếm

Back
Top