I have a list of pointers that can be from diferent derived classes of BaseClass. I want to duplicate some items who's indexes are in m_listEntities_selected (a list of type int). newPosition() is a virtual member. Can I cast 'entity', since I don't know the type of the item at the specified position?

Qt Code:
  1. for(int i=0;i<m_listEntities_selected.size();i++)
  2. {
  3. BaseClass *entity = new BaseClass;
  4. entity = dynamic_cast< typeid (m_listEntities.at(m_listEntities_selected[i]) ) > (m_listEntities.at(m_listEntities_selected.at(i))); // this is the error
  5. *entity = *m_listEntities.at(m_listEntities_selected.at(i) );
  6. entity->newPosition(point3d-point_base_copy);
  7. m_listEntities.append(entity);
  8. }
To copy to clipboard, switch view to plain text mode 

I can solve my problem with a switch case, because I have virtual members in the derived classes that give a string with the type but that will be much less elegant and I will have to modify the switch case every time I create a new derived class. Any sugestion ?