title: Deserializing unknown inherited type [C++]
body: <p>Lets say I have a class which routes messages to their handlers. This class is getting the messages from another class who gets the messages through socket. So, the socket gets a buffer containing some sort of message.</p>
  
  <p>The class that routes the messages is aware of the message types. Every message is inheriting Message class which contains a message ID, and of course adds paraemters of it's own.</p>
  
  <p>The problem is, how can I transfer the message from the buffer to be an actucal message instance of the correct type?</p>
  
  <p>For exmaple, I have a DoSomethingMessage that inherites Message. I get the buffer containing the message, but I need somehow to convert the buffer back to DoSomethingMessage, without really knowing it's a DoSomethingMessage.</p>
  
  <p>I could have transfer the buffer to the MessageRouter, and there check by the ID and create the right instance, but it's seemes like a really bad design to me.</p>
  
  <p>Any suggestions?</p>