title: How to convert from base class to derived class?
body: <p>I want to make a multi-threaded model in which the server main loop will not be stalled by pending database transactions. So I made a few simple classes, this is a very simplified version:</p>
  
  <pre><code>enum Type
  {
      QueryType_FindUser      = 1 &lt;&lt; 0,
      QueryType_RegisterUser  = 1 &lt;&lt; 1,
      QueryType_UpdateUser    = 1 &lt;&lt; 2,
      //lots lots and lots of more types
  };
  
  class Base
  {       
  public:
      Type type;
  };
  class User: public Base
  {   
  public:
      std::string username;
      User(std::string username)
          :username(username)
      {type = QueryType_FindUser;}        
  };
  </code></pre>
  
  <p>Now when I transfer the data as a <code>Base</code>, I want to convert it back to <code>User</code> class again:</p>
  
  <pre><code>concurrency::concurrent_queue&lt;QueryInformation::Base&gt; BackgroundQueryQueue;
  void BackgroundQueryWorker::Worker()
  {
      while(ServerRunning)
      {
          QueryInformation::Base Temp;
          if(BackgroundQueryQueue.try_pop(Temp))
          {
              switch(Temp.type)
              {
                  case QueryInformation::Type::QueryType_FindUser:
                  {
                      QueryInformation::User ToFind(static_cast&lt;QueryInformation::User&gt;(Temp));//error here
                      //do sql query with user information
                      break;
                  }
                  //etc
              }
          }
          boost::this_thread::sleep(boost::posix_time::milliseconds(SleepTime));
      }
  }
  </code></pre>
  
  <p>Where I marked the <code>//errorhere</code> line it says that there is no user-defined conversion from <code>Base</code> to <code>User</code>, what should I do? How can I define this conversion?</p>
  
  <p>I'm new to polymorphism so an additional explaination why this doesn't compile would be also great :)
  From what I understood about polymorphism it should be doable to convert freely between base&lt;->derived..</p>