In the C++ code below, am I guaranteed that the ~obj() destructor will be called after the // More code executes? Or is the compiler allowed to destruct the
A typical example of this, just as your question is the boost::scoped_ptr (or similar std::auto_ptr) :
{ boost::scoped_ptr< MyClass > pMyClass( new MyClass ); // code using pMyClass here } // destruction of MyClass and memory freed