“We do not use C++ exceptions” — What's the alternative? Let it crash?

前端 未结 7 437
南旧
南旧 2021-02-01 14:25

\"We do not use C++ exceptions.\"

If you don\'t use exceptions, what happens when there\'s an error? You just let the program crash?

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 14:57

    No, the alternative is to do what people have done for ages in C... you return an error status code that indicates whether the function succeeded or not, and depending on the ways in which it can fail, you might have one or more out parameteters in which you indicate the way in which it failed (or you incorporate the type of failure in the error status code, again it's a case-by-case thing).

提交回复
热议问题