a n delete p is a two-step procedure it calls the


A: N delete p is a two-step procedure: it calls the destructor, and then releases the memory. The code developed for delete p is functionally similar to this (supposing p is of type Fred*):

// Original code: delete p;

if (p != NULL) { p->~Fred(); operator delete(p);

}                                              

The statement p->~Fred() calls the destructor for the Fred object pointed to by p.

The statement operator delete(p) calls memory deallocation primitive, void operator delete(void* p). This primitive is same in spirit to free(void* p). (Note down, however, that these two are not interchangeable; for example there is no guarantee that the two memory deallocation primitives even employ the same heap!)

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: a n delete p is a two-step procedure it calls the
Reference No:- TGS0217524

Expected delivery within 24 Hours