Order and point of calling destructor

后端 未结 4 914
盖世英雄少女心
盖世英雄少女心 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:26

    The destruction happens in reverse order of construction: first m2 then m1.

    Compiler can never delay object's lifetime behind scope end (}).

提交回复
热议问题