Mistake: treating an array of derived objects as an array of base objects. A derived pointer can replace a base pointer, but array indexing uses the declared element size. Because derived objects may be larger, pointer arithmetic reaches the wrong locations. section 8.10
A cast that appears to work
With B and D, printArray(const B a[]) accepts both B* and D*. Printing the D array produces 0, 1, 0, 1 instead of four consistent derived elements. Passing the same pointer to deleteArray is also unsafe: destruction reports only B objects, not D objects. The apparent polymorphism hides an array-layout error.
