$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2006-01-11 11:49:54
Olga Gerchikov wrote:
> Suppose I have this function in c++:
> 
> 
>   int* f(int size)
>  {
>     int * array = new int[size];
>     return array;
> 
> }
> 
> Is there a safe idiom to prevent memory leak?
yes.
> Should i use auto_ptr in
>  C++?
yes, but not here.
>  Or should I use the smart pointer library in boost? Which is the
> simplest solution?
use std::vector<int> in the above case:
   std::vector<int> v( size );
-Thorsten