This is a fundamental aspect of C++ that needs understanding. It causes confusion that has its ground. Look a the example:
char* myChar1 = new char[20];
char* myChar2 = (char*)malloc(20);
In spite of the fact that both pointers have the same type, you should use different methods to release objects that they are pointing at:
delete [] myChar1;
free(myChar2);
Note that if you do:
char *tmp = myChar1;
myChar1 = myChar2;
myChar2 = myChar1;
After that you need:
delete [] myChar2;
free(myChar1);
You need to track the object itself (i.e. how it was allocated), not the place where you keep a pointer to this object. And release the object that you want to release, not the place that stores info about this object.