How does friendship relation in C++ affect inheritance hierarchies, if at all? 

  • It overrides private inheritance. 
  • It allows base classes to access derived class members. 
  • It doesn't directly affect inheritance hierarchies. 
  • It breaks the "is-a" relationship in OOP.
Friendship is orthogonal to inheritance in C++. Declaring a function or class as a friend of another class doesn't have a direct impact on the inheritance hierarchy of classes. A friend function/class of a base class isn't automatically a friend of its derived classes.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *