I actually want to describe my problem first. In my code I've a base class with name Employee then I've 4 more classes. I wanted to make my class abstract (basically i was using polymorphism concept). I made a pointer array with type of base class and add objects in it(unnamed objects on heap). Now i wanted to deallocate objects. I used delete[i] array and delete array[i] both were working(one at a time). Can someone please explain the difference between both of them? Why both were working if delete[i] is wrong?
I was using delete[i] array or delete array[i] with for loop.
main is like:
Employee *arr[10];
arr[0] =new SalariedEmployee ("first name","last name","number",200);
now i want to delete this object
delete[i] arrayseems invalid, you probably meandelete[] array;