Can you guarantee destructor order when objects are declared on a stack?

后端 未结 5 692
-上瘾入骨i
-上瘾入骨i 2021-02-12 14:34

I have code that controls a mutex lock/unlock based on scope:

void PerformLogin()
{
    ScopeLock < Lock > LoginLock( &m_LoginLock );

    doLoginComma         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-12 14:53

    Yes, destructors are called in the reverse order of construction.

提交回复
热议问题