C++,项目管理
面向对象思考
这个作者很懒,什么都没留下…
展开
-
02-字符串哈希
字符串哈希原理和用途原创 2022-11-20 16:20:17 · 280 阅读 · 0 评论 -
C++核心准则E.27:如果无法抛出异常,系统化运用错误处理代码
E.27: If you can't throw exceptions, use error codes systematicallyE.27:如果无法抛出异常,系统化运用错误处理代码Reason(原因)Systematic use of any error-handling strategy minimizes the chance of forgetting to handle an error.系统化运用任何错误处理策略都可以减少忘记处理某个错误的可能性。See als..翻译 2020-10-10 21:07:56 · 278 阅读 · 0 评论 -
C++核心准则E.17:不要试图在所有函数中捕捉所有异常
E.17: Don't try to catch every exception in every functionE.17:不要试图在所有函数中捕捉所有异常Reason(原因)Catching an exception in a function that cannot take a meaningful recovery action leads to complexity and waste. Let an exception propagate until it reaches a.翻译 2020-09-30 14:50:12 · 284 阅读 · 0 评论 -
C++核心准则E.16:析构函数,内存释放和swap操作永远不能失败
E.16: Destructors, deallocation, andswapmust never failE.16:析构函数,内存释放和swap操作永远不能失败Reason(原因)We don't know how to write reliable programs if a destructor, a swap, or a memory deallocation fails; that is, if it exits by an exception or simply does...翻译 2020-09-29 14:26:20 · 387 阅读 · 0 评论 -
C++核心准则E.15: 使用引用形式捕捉继承体系中的异常
E.15: Catch exceptions from a hierarchy by referenceE.15:使用引用形式捕捉继承体系中的异常Reason(原因)To prevent slicing.为了避免截断。Example(示例)void f(){ try { // ... } catch (exception e) { // don't: may slice // ... }}I...翻译 2020-09-28 15:08:54 · 307 阅读 · 0 评论 -
C++核心准则E.13: 直接拥有一个对象所有权时永远不要抛出异常
E.13: Never throw while being the direct owner of an objectE.13: 直接拥有一个对象所有权时永远不要抛出异常Reason(原因)That would be a leak.那样做会发生泄露。Example(示例)void leak(int x) // don't: may leak{ auto p = new int{7}; if (x < 0) throw Get_me_out_of...翻译 2020-09-26 15:03:35 · 287 阅读 · 0 评论 -
C++核心准则E.12: 当不可能或不愿意通过抛出异常退出函数时使用noexcept
E.12: Usenoexceptwhen exiting a function because of athrowis impossible or unacceptableE.12: 当不可能或不愿意通过抛出异常退出函数时使用noexceptReason(原因)To make error handling systematic, robust, and efficient.为了让错误处理更系统化,健壮和高效。Example(示例)double compute(...翻译 2020-09-25 14:51:13 · 284 阅读 · 0 评论 -
C++核心准则ES.10:每次只定义一个名称
ES.10: Declare one name (only) per declarationES.10:每次只定义一个名称Reason(原因)One declaration per line increases readability and avoids mistakes related to the C/C++ grammar. It also leaves room for a more descriptive end-of-line comment.每行一个声明的做法可以提高可.翻译 2020-06-13 17:06:22 · 344 阅读 · 0 评论