delete a structure pointer, but type is changed to char* ?

December 24, 2009 - 9:51 pm

I have one structure called "abc".
So,

abc *pabc = new abc;

char* pChar = (char*)pabc;

delete pChar;
// is the above statement is valid in C++. is there any memory leak !

In most cases this will work, but it is not guaranteed to work and so it should be avoided.

One Response to “delete a structure pointer, but type is changed to char* ?”

  1. Paul Says:

    In most cases this will work, but it is not guaranteed to work and so it should be avoided.
    References :

Leave a Reply