If I have the following lines inside a loop:
Type *unite = new Type(newSize);
or
double *array= new double[anySize];
what is the behavior in what concerns to memory if I don’t have delete operators inside it? It will be constantly allocating objects and arrays on different memory locations, and therefore memory leaks?
Yes it will. This:
will allocate 10 objects of type
Type, all at different locations. None of them will be deallocated, and at the end you will not have a pointer to any of them. You will leak10 * sizeof(Type)bytes of memory.Similarly, this
will for the same reason leak
10 * anySize * sizeof(double)bytes of memory.