Order and point of calling destructor
问题 Lets say I have two local objects. When the function returns, is it guaranteed which one will go out of the scope first? For example: I have a class like this: class MutexLock { /* Automatic unlocking when MutexLock leaves a scope */ public: MutexLock (Mutex &m) { M.lock(); } ~MutexLock(Mutex &m) { M.unlock(); } }; This is a very common trick used to automatically release the mutex when going out of scope. But what if I need two mutexes in the scope? void *func(void *arg) { MutexLock m1;