using inheritance or friendship

while programming i mostly don't see a use in class friendship unless i want to access private members and even than i can make them protected and inherit them to access them.
my question is when would be a good style to use friendship over inheritance and vise versa ?
First decide if it is logically correct for a class to inherit from another class.
For instance, for public inheritance: https://en.wikipedia.org/wiki/Liskov_substitution_principle

Once that is decided:

To grant access to a particular member from all derived classes (on an object of a derived type), make the member protected.

To grant access to all members from a non-member functions or an unrelated (via inheritance) class, use a friend declaration.
Sutter writes in http://www.gotw.ca/publications/mill06.htm
Inheritance is often overused, even by experienced developers. Always minimize coupling: If a class relationship can be expressed in more than one way, use the weakest relationship that's practical. Given that inheritance is nearly the strongest relationship you can express in C++ (second only to friendship), it's only really appropriate when there is no equivalent weaker alternative.

closed account (48T7M4Gy)
Some more to add to the melting pot.
http://stackoverflow.com/questions/18085169/whats-the-difference-between-friendship-and-inheritance

friendship crops up regularly in the ubiquitous << and >> operator overloads. But after that it seems not so much.

Overall, in light of all the comments here I treat them as separate concepts rather than alternatives. Unfortunately (or maybe fortunately), Java does a better job of inheritance than C++ - there are no friends IIRC - but a lousy job of operator overloading.
Thank you for the information now i need to review and organise it!
Topic archived. No new replies allowed.