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 that counts from 0 to 99 and prints these numbers to the terminal ie it prints 00, 01, 02, 03, 04, 05, ....,99. Graphics 1. Write a program in rPeANUt that

My file pointer is going to the location which i specified and writing the value but it is in next line so,please help me iam developing in visual studio6

Program of swapping two varibales: void swap(int *, int *);   // This is swap's prototype int main() {                 int x = 5, y = 7;                 swap(&x, &

Explain the Command Line Parameters? The Command line arguments are parameters supplied to a program from the operating system. These arguments are parameters accepted to main

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

where to use tower of honoi?

solution of problem based on poiter

This is a test program that tests the Student and ITECH7603Class classes.     In this assignment you are provided with three input text files associated with this program:

For the circuit shown in Figure, verify the p.d. across resistor R3. If the total resistance of the circuit is 100Ω, verify the current flowing by resistor R1. Find also the