Quote:Original post by Basiror
@snk_kid:let me guess the placement new doesn t initialize the VFT pointer right?
the compiler sets up the VFT pointer as i just read on google
[headshake] I don't think you understood or get the point of my message, for one thing using placement new for pointer types isn't necessary (you can do but its not needed) as pointers are
POD-types therefore an array of pointers is also a
POD-type.
Secondly
in general if you where going to separate allocation/deallocation & construction/destruction for efficiency reasons (as is the case for std::vector) using calloc for your method of allocating
uninitialized memory is naive because calloc zero initializes elements of an array.
This is pointless if you are going to use placement new because the whole point of placement new is to initialize
uninitialized memory properly, a normal method of allocating
uninitialized memory is to either use
malloc or using operator new
via explicit invocation or something similar becasue they both allocate
uninitialized memory, no time is wasted as is the case with calloc.