POV-Ray : Newsgroups : povray.off-topic : C++ destructor question : Re: C++ destructor question Server Time
3 Sep 2024 21:17:07 EDT (-0400)
  Re: C++ destructor question  
From: John VanSickle
Date: 6 Aug 2010 07:44:38
Message: <4c5bf5a6$1@news.povray.org>
Darren New wrote:
> Speaking of RAII and all...
> 
> When an object is stuck into a standard collection in C++, and then the 
> collection goes out of scope, what order is defined on the destructors 
> of the things in the collection? I wouldn't imagine it's the order they 
> were inserted (at least for a random-access type collection).  Does a 
> stack destruct in a different order than a queue does, for example? Does 
> a vector always destruct on increasing indexes?

See if you can discern the order of construction.  The safest 
destruction reverses this order.

Regards,
John


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.