What is the impact of using a friend function on encapsulation in C++?
- It enhances it.
- It doesn't affect it at all.
- It undermines it.
- It strengthens the class hierarchy.
Friend functions can access the private and protected members of a class. This can lead to a breach in encapsulation as they can potentially expose or modify class internals outside the usual member function framework. This undermines the very purpose of encapsulation.
Loading...
Related Quiz
- What is the minimum requirement for a recursive function to terminate successfully?
- A function that calls itself directly or indirectly is known as a _______ function.
- What does the -> operator do in the context of pointers in C++?
- Which of the following is a correct way to declare a function pointer in C++?
- What does the "++" symbolize in the C++ programming language?