Wednesday 22 February 2012

What is the sequence of destruction of local objects? | Constructor in C++

The destructor is executed in the reverse order of a constructor. Firstly, the objects are constructed, methods are invoked on them, and then they are destructed. In the following example, a's destructor will be executed after b's destructor.
void abc()
{
cat a;
cat b;
}