Keeping this in view, can friend classes be inherited?
Friendship is neither inherited nor transitive. friend only applies to the class you explicitly make it friend and no other class. You can create (static) protected methods in the parent that will allow you to do things like that.
Likewise, which function Cannot be inherited? C++ - Constructor & Friend FunctionConstructor cannot be inherited but a derived class can call the constructor of the base class. In C++, friend is not inherited. If a base class has a friend function, then the function does not become a friend of the derived class(es).
Also question is, can we use friend function in inheritance?
No, friend functions are not inherited. Because friend function is using the data members available in base class only. Not the data members of derived class . Since derived class is a type of base class So, friend function is working fine.
Can friend functions access private members?
Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful to allow a particular class to access private members of other class. For example a LinkedList class may be allowed to access private members of Node.
