Can a friend function be a member function of another class?
- Always
- Never
- Only if it's a static member function.
- Yes, if it's declared as a friend in the original class.
A friend function can indeed be a member function of another class. In this context, one class allows a member function of another class to access its private and protected members by declaring that member function as a friend.
Loading...
Related Quiz
- In the context of recursion, what is a "recursive case"?
- You are developing a multi-threaded application where multiple clients are sending data to a server. Each client is handled in a separate thread and communicates with the server in a loop. If a client sends an incorrect data format, the server should ignore it and wait for the next data. How might continue be used in this case?
- Can a friend function of a class access the private members of that class?
- In C++, if a class makes a non-member function its friend, that function gets the ability to access the _______ and _______ members of the class.
- In C++, an enum can be used to create _______.