, new delete . . , , , , Valgrind.
, new [], delete [] , , new, delete.
Remember to mix new- deletewith malloc- freeor with new[]- delete[], because these functions are not designed to work with each other, for example, never do this:
int *a = (int*)malloc(10*sizeof(int));
delete a;
but this one
int *a = new int[10];
delete[] a;
As Tibor said, using a pointer is not so bad, but, as always, “great responsibility comes with great power”: P
source
share