Assume I have a sort of Observer-Pattern, where message objects are sent to observers. So I have say class Message as the top of a hierarchy and observers working on them. Concrete messages are derived from that and identified by an ID, by which it is possible to cast the message to its concrete subtype and work with it. (This is existing code i need to work on) Now there is other functionality, let us call it A, B, ... Currently, there's a huge class hierarchy which is like
class Message class MessageWithA : public Message class MessageWithAandB : public MessageWithA
Now the functionalities A, B etc are (mostly) completely independent of the messaging system and also among then. Wouldn't it be better to derive the concrete classes like
class MessageWithA : public Message, public A class MessageWithAandB : public Message, public A, public B ?
(where A and B are classes that concentrate on the strict necessary to implement the appropriate functionality)
Does this pattern have a name? And is it used in C++? I was thinking about "Mix-ins", but the definition of that explicitly states that no inheritance is used. Does what I want to do make any sense?