Can the C++ `new` operator ever throw an exception in real life?

前端 未结 18 2203
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 08:40

Can the new operator throw an exception in real life?

And if so, do I have any options for handling such an exception apart from killing my application?

18条回答
  •  渐次进展
    2021-01-30 09:07

    You don't need to handle the exception in every single new :) Exceptions can propagate. Design your code so that there are certain points in each "module" where that error is handled.

提交回复
热议问题