On Fri, 20 Oct 2000, Lior Silberman wrote:

> I know this _feels_ bad, but I think the most efficient implementation
> will be to handle the temporary ourselves:
> 
> Menu* Menu::expand (Buffer* buf)
>       {
>       Menu *resulting_menu = new Menu();
>       ...
>       // add stuff to the new menu
>       ...
>       return resulting_menu;
>       }
> 
> Which can be used as:
> 
> Menu *tmp = menu.expand();
> ...
> ...
> delete tmp;

At least if we go this way we should use auto_ptr<Menu> as in:
{
   auto_ptr<Menu> tmp( menu.expand() );
   ...
   ...
}

This is also better since we reduce the risk of exceptions and/or returns
before the delete.

-- 
  Baruch Even

http://techst02.technion.ac.il/~sbaruch/   (My Site)
http://www.redrival.com/jindor/            (My brothers AD&D site)

" Learn to laugh ... it's the path to true love! " 
   - The Angel in the movie Michael


Reply via email to