See the Bridge pattern in [6].
The declaration file:
// If you are not planning on applying dynamic_cast<> to // the public interface base class, then it does not need to be virtual struct Book : boost::impl_ptr<Book>::shared { Book(args); string const& title() const; string const& author() const; }; struct ThickBook : Book { ThickBook(args); }; struct ThickestBook : ThickBook { ThickestBook(args); };
The implementation file:
template<> struct boost::impl_ptr<Book>::implementation { implementation(args) {...} virtual ~implementation() {...} ... }; struct ThickBookImpl : boost::impl_ptr<Book>::implementation { ThickBookImpl(args) : implementation(args) {...} ... }; struct ThickestBookImpl : ThickBookImpl { ThickestBookImpl(args) : ThickBookImpl(args) {...} ... }; ThickBook:: ThickBook(args) : Book(boost::impl_ptr<Book>::null()) { emplace<ThickBookImpl>(args); ... } ThickestBook::ThickestBook(args) : ThickBook(boost::impl_ptr<ThickBook>::null()) { emplace<ThickestBookImpl>(args); ... }