In C++ what are the benefits of using exceptions and try / catch instead of just returning an error code?

后端 未结 13 852
遥遥无期
遥遥无期 2020-12-04 19:58

I\'ve programmed C and C++ for a long time and so far I\'ve never used exceptions and try / catch. What are the benefits of using that instead of just having functions retur

13条回答
  •  北海茫月
    2020-12-04 20:41

    Possibly an obvious point - a developer can ignore (or not be aware of) your return status and go on blissfully unaware that something failed.

    An exception needs to be acknowledged in some way - it can't be silently ignored without actively putting something in place to do so.

提交回复
热议问题