title: std::shared_ptr of abstract class to instantiate derived class
body: <p>I am trying to use <code>std::shared_ptr</code>, but i am not sure if i can use <code>shared_ptr</code> for a abstract class and call a derived class from this smart pointer. Here is the code that i have at present</p>
  
  <pre><code>IExecute *ppCIExecuteExecuteOperation = NULL;
  
  for(int i = 0; i &lt; 3; ++i)
  {
      switch (stOperationType.key)
      {
          case E_OPERATIONKEY::DrawCircle:
          pCIExecuteExecuteOperation = new CCircle();
          break;
          case E_OPERATIONKEY::DrawSquare:
          pCIExecuteExecuteOperation = new CSquare();
          break;
          case E_OPERATIONKEY::Rhombus:
          pCIExecuteExecuteOperation = new CRehombus();
          break;
          default:
          break;
      }
  } 
  pCIExecuteExecuteOperation-&gt;Draw();
  </code></pre>
  
  <p>Here IExecute is a abstract class and CCircle, CSquare, CRhombus is a derived class of IExecute.</p>
  
  <p>All I want to do is use <code>shared_ptr&lt;IEXectue&gt;pCIExecuteExecuteOperation(nullptr)</code>
  and inside a switch statement make it point to one of the derived class, How can i achieve this?</p>
  
  <p>Edit:
  The answers were to use make_shared or reset() </p>
  
  <p>Thanks guys, I dint expect it to be so easy.</p>