Click to See Complete Forum and Search --> : delete vs. delete []


kjetil7
April 25th, 2002, 06:09 AM
Hi,

Does anyone know if there is possible to decide in runtime either to call:


delete someptr;




or


delete [] someptr;




What about smart pointers? How do they know which one to call?



Kjetil Haga

kjetil7
April 25th, 2002, 06:27 AM
Hi again...

I've taken a look at boost and they have a separate smart pointer for arrays (shared_array). Since the boosters have made a separate class for handling dynamic arrays, I guess this is not possible. Please correct me if I'm wrong....

Thanks.



Kjetil

NMTop40
April 25th, 2002, 10:10 AM
the solution is never to use arrays and then you need never use delete []

use std::vector instead of arrays.


The best things come to those who rate