Quote:
Originally Posted by sharmila
Can you tell me how to check whether memory is allocated or not manually?
By watching the memory in the memory watcher available with VC++ 6
Quote:
Originally Posted by sharmila
and also about placement new operator?
Here is an example
Code: CPP
#include <new>        // Must #include this to use "placement new"
 #include "Fred.h"     // Declaration of class Fred
 
 void someCode()
 {
   char memory[sizeof(Fred)];     // Line #1
   void* place = memory;          // Line #2
 
   Fred* f = new(place) Fred();   // Line #3 (see "DANGER" below)
   // The pointers f and place will be equal
 
   ...
 }
Line #1 creates an array of sizeof(Fred) bytes of memory, which is big enough to hold a object.
Line #2 creates a pointer place that points to the first byte of this memory.
Line #3 essentially just calls the constructor Fred::Fred(). The this pointer in the Fred constructor will be equal to place. The returned pointer f will therefore be equal to place.