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 count the prime number in array

how to make a diamond from steric

#write a program that counts the number of occurances of the string in the n-th padovan string p(n)


Record separation problem Let us assume that a particular database program manages a simple mailing list which consists of one record for each person on the list, and a number of f

Why PHP is sometimes called as embedded scripting language? PHP is a high level language that is used to allow users to write and understand it in human readable form and also

By pressing ‘6’ (i.e. key’6’ one time) on the keypad, the mobile shows ‘m’ on display screen in write text message area

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

when you allocate memory with new[], you ought to free the memory via delete[]. While you allocate memory along 'new', then use 'delete' with no the brackets. You employ new[] to a

C++ improves on many of C's features and provides object-oriented programming capabilities used for software production, quality and reusability. C++ was developed by Bjarne Strons