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

后端 未结 13 888
遥遥无期
遥遥无期 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

    Google's C++ Style Guide has a great, thorough analysis of the pros and cons of exception use in C++ code. It also indicates some of the larger questions you should be asking; i.e. do I intend to distribute my code to others (who may have difficulty integrating with an exception-enabled code base)?

提交回复
热议问题