What is the difference between the friend class and inheritance consept in C++? [closed]

In C++ ,friend class allows us to inherit the proprieties of one class to another class(es) which is also possible using inheritance. And also in inheritance we can set different levels of privileges to the child class(es) depending on our requirements, which suggests inheritance is more useful than friend class. Then what more can friend class do which cannot be done using inheritance? Why is friend class introduced when there is already inheritance property which has even more functionalities?

• Sounds like a question for stackoverflow. – Yuval Filmus Feb 29 '16 at 13:01
• This isn't the place to ask about the difference in usage, but it might be reasonable to ask about the difference in meaning. Inheritance (should) denote Liskov substitutability, which is a different notion from privacy. – Pseudonym Feb 29 '16 at 13:35
• – Bojack Feb 29 '16 at 14:07
• To whomever keeps flagging these comments: they are neither rude nor offensive so they won't be removed. In fact, the comments here strike me as particularly constructive, as they tell the OP 1) where the question is more likely to be well-received, 2) how this question may be refocused to be ontopic here, and 3) where an answer can be found. – Raphael Feb 29 '16 at 20:11
• Let's say your cat has fleas. That's the cat's private business. But you, as the cat's owner, want access to that private business. Without being a cat yourself. That's the important thing: Inheritance would mean only cats can determine if one cat has fleas. "friend" classes and functions mean other classes can as well. – gnasher729 Jan 10 '17 at 10:50

To declare a class (or a function) a friend allows the friend to access private members [the naming in C++ is not my fault!] (data or function) directly. They aren't "inherited" in any meaningful way. Yes, it creates a interdependency, but very different and a lot weaker than inheritance does.