RE:more about new with placement

From: Masaharu Goto (MXJ02154@niftyserve.or.jp)
Date: Sun Jul 05 1998 - 15:02:00 MEST


Xie,

New with placement should be as simple as follows. First, use
'new (arena) TYPE[INDEX];' , second, don't use delete on it.  
In this case you use the arena as float, so just don't delete it.
If you want to use the arena as class object, you should use explicit
destructor. 

Masaharu Goto

#include <stdio.h>

main()
{
 float *test[10000][1000];

 for(int i=0;i<10000;i++)
   for(int ii=0;ii<1000;ii++)
   { test[i][ii] = new (arena) float[10000];
     for(int j=0;j<10000;j++)
       test[i][ii][j] = i*j;
   }
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:34 MET