   deleting a void* - which method should be used?
  I'm wondering if code like:void* Left = new double(0.01);void* Right = new int(1);delete Left;delete Right;will perform as expected or should I use:double** LeftP = &((double*)Left);int** RightP = &((int*)Right);delete *Left;delete *Right;instead?   
  You have to cast it back to the original type.;  You should probably avoid void * entirely in the first place if at all possible.  If not then you should delete reinterpret_cast< Type * >(pointer).  Never delete a void * directly - it's undefined behaviour.Σnigma   ;Quote:Original post by TertsiI'm wondering if code like:void* Left = new double(0.01);void* Right = new int(1);delete Left;delete Right;will perform as expectedyesQuote:or should I use:double** LeftP = &((double*)Left);int** RightP = &((int*)Right);delete *Left;delete *Right;instead?most defiantly not this may well give a segmentation error, due to the fact that the second pointer is not dynacically created and has local scope.;Quote:Original post by Anonymous PosterQuote:Original post by TertsiI'm wondering if code like:void* Left = new double(0.01);void* Right = new int(1);delete Left;delete Right;will perform as expectedyesWrong. Deleting a void * is undefined.Quote:Quote:or should I use:double** LeftP = &((double*)Left);int** RightP = &((int*)Right);delete *Left;delete *Right;instead?most defiantly not this may well give a segmentation error, due to the fact that the second pointer is not dynacically created and has local scope.Wrong again. This will work fine, although you're much better off with:delete (double *)Left;delete (int *)Right;There's no need to be messing about with pointers-to-pointers.   ;  Your first snippet won't compile, because in c++ you can't assign a pointer to void*-type without casting.   