CObject::operator delete

For the Release version of the library, operator delete frees the memory allocated by operator new.

void PASCAL operator delete(
   void* p 
);
void PASCAL operator delete(
   void* p,
   void* pPlace
);
void PASCAL operator delete(
   void* p,
   LPCSTR lpszFileName,
   int nLine 
);

Remarks

In the Debug version, operator delete participates in an allocation-monitoring scheme designed to detect memory leaks.

If you use the code line

#define new DEBUG_NEW

before any of your implementations in a .CPP file, then the third version of delete will be used, storing the filename and line number in the allocated block for later reporting. You do not have to worry about supplying the extra parameters; a macro takes care of that for you.

Even if you do not use DEBUG_NEW in Debug mode, you still get leak detection, but without the source-file line-number reporting described above.

If you override operators new and delete, you forfeit this diagnostic capability.

Example

See CObList::CObList for a listing of the CAge class used in the CObject examples.

void CAge::operator delete(void* p)
{
   free(p);
}

void CAge::operator delete(void *p, LPCSTR lpszFileName, int nLine)
{
   UNREFERENCED_PARAMETER(lpszFileName);
   UNREFERENCED_PARAMETER(nLine);
   free(p);
}

Requirements

Header: afx.h

See Also

Reference

CObject Class

Hierarchy Chart

CObject::operator new

Other Resources

CObject Members