Its not OO without inheritance is a widely used idea. Is-a relationship is a much stronger relationship than has-a or use-a. For the management of dependences composition/membership is much better than inheritance.
Use as strong relationship as neccessary but no stronger.
// x.h: sample header
// version 3
#include <iosfwd>
#include "a.h" // class A
class C;
class E;
class X : public A
{
public:
X( const C&);
B f(int, char*);
C f(int, C);
C& g(B);
E h(E);
virtual std::ostream& print(std::ostream&) const;
private:
// opaque pointer to forward-declared class
class XImpl *pimpl_;
};
inline std::ostream& operator<<( std::ostream& os, const X& x)
{
return x.print(os);
}
// file x.cpp
#include "x.h"
#include "b.h" // class B
#include "c.h" // class C
#include "d.h" // class D
struct XImpl
{
B b_;
std::list<C> clist_;
D d_;
};