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.
- public, private
- private, protected
- public, static
- static, protected
In C++, when a non-member function is declared as a friend of a class, it can access both private and protected members of that class. Public members are accessible to all functions, so the unique ability granted by the friendship is access to the private and protected members.
Loading...
Related Quiz
- In a system that processes user commands, you notice that the if-else chain for command processing has become excessively long and difficult to manage. Which refactorization strategy might be most effective?
- How does a range-based for loop work in C++11 and above?
- What does the new operator do in C++?
- When a pointer is passed to a function, the function receives _______?
- In C++20, using enum with _______ allows specifying the underlying type and scope.