What's the best technique for exiting from a constructor on an error condition in C++

后端 未结 8 850
北荒
北荒 2020-12-14 08:21

What\'s the best technique for exiting from a constructor on an error condition in C++? In particular, this is an error opening a file.

Thanks for the responses. I\'

8条回答
  •  春和景丽
    2020-12-14 08:48

    If you object after the error can not perform its actions - you have to throw. If it can - log you error and change the construction logic.

提交回复
热议问题