Order and point of calling destructor

后端 未结 4 898
盖世英雄少女心
盖世英雄少女心 2020-12-07 01:42

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 thi

4条回答
  •  庸人自扰
    2020-12-07 02:48

    The object is always destroyed when it goes out of scope - this is not java. f Will get destroyed where you indicate and will never be destroyed at the end of func. in general the destructors are called in order reverse to the order of their construction.

提交回复
热议问题