Tell me how in C ++ you can allocate memory for an array of classes, so that each element can be determined not only by the type of this class, but also the type of heirs of the original class. Those. There is for example a class cClassParent and two classes of the successor cClassChild1 and cClassChild2. How to allocate memory for an array of cClassParent, so that the i-th element of the array could be redefined as cClassChildN tried, for example
cClassParent* obj = new cClassParent[3]; obj[2] = cClassChild1();
does not work