What are the two steps that happen while i say delete p?, C/C++ Programming

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!)

 

Posted Date: 3/19/2013 8:40:45 AM | Location : United States







Related Discussions:- What are the two steps that happen while i say delete p?, Assignment Help, Ask Question on What are the two steps that happen while i say delete p?, Get Answer, Expert's Help, What are the two steps that happen while i say delete p? Discussions

Write discussion on What are the two steps that happen while i say delete p?
Your posts are moderated
Related Questions
write a program to calculate the cuboid

Can I free() pointers allocated  along with new? Can I delete pointers allocated along with malloc()? A: No. It is completely legal, moral, and wholesome to employ malloc() a

What are header files? What are their uses? - Header files are also known as library files. - They carry two significant things: definitions and prototypes of functions bein

Project Description: Prepare software that will work with our USB hardware that easily lets you backup all the pictures in your computer into the USB stick in one single step. Once

Write a C program to input five numbers and print them out on a new line Write a C program to input three real numbers and print them out as follows:   The first variable is

#question.gsdjfhjhjfkfk.

#C Why don''t online compilers support the header file? What can I do to resolve this? PS. I have tried , does''nt work either. Thannk in advance.

d county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Necklaces

How do you write the code for summations

Consider the following mathematical function: (a) Write a procedure that computes f by means of a recursive process (b) Write a procedure that computes f by means of an