上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页
摘要: When you employ a new expression (i.e., dynamic creation of an object via a use of new), two things happen. First, memory is allocated (via a function 阅读全文
posted @ 2021-09-03 09:25 MyCPlusPlus 阅读(38) 评论(0) 推荐(0) 编辑
摘要: ,Item 13 introduces the idea of using smart pointers like auto_ptr or tr1::shared_ptr to hold the result of a call to a factory function like createIn 阅读全文
posted @ 2021-09-02 19:40 MyCPlusPlus 阅读(53) 评论(0) 推荐(0) 编辑
摘要: For example, suppose you’re using a C API to manipulate mutex objects of type Mutex offering functions lock and unlock: void lock(Mutex *pm); // lock 阅读全文
posted @ 2021-09-02 17:38 MyCPlusPlus 阅读(39) 评论(0) 推荐(0) 编辑
摘要: Consider this code: class Investment { /*...*/ }; // root class of hierarchy of investment types Investment* createInvestment(); // return ptr to dyna 阅读全文
posted @ 2021-09-01 17:13 MyCPlusPlus 阅读(32) 评论(0) 推荐(0) 编辑
摘要: Consider: class Date { }; // for dates in time class Customer { public: //... // as before private: std::string name; Date lastTransaction; }; class P 阅读全文
posted @ 2021-08-31 10:51 MyCPlusPlus 阅读(35) 评论(0) 推荐(0) 编辑
摘要: An assignment to self occurs when an object is assigned to itself: class Widget { ... }; Widget w; //... w = w; // assignment to self If you try to ma 阅读全文
posted @ 2021-08-31 10:50 MyCPlusPlus 阅读(41) 评论(0) 推荐(0) 编辑
摘要: For this code: int x, y, z; x = y = z = 15; // chain of assignments The way this is implemented is that assignment returns a reference to its left-han 阅读全文
posted @ 2021-08-30 11:22 MyCPlusPlus 阅读(32) 评论(0) 推荐(0) 编辑
摘要: If Transaction had multiple constructors, each of which had to perform some of the same work, it would be good software engineering to avoid code repl 阅读全文
posted @ 2021-08-30 11:03 MyCPlusPlus 阅读(49) 评论(0) 推荐(0) 编辑
摘要: Destructors should never emit exceptions. If functions called in a destructor may throw, the destructor should catch any exceptions, then swallow them 阅读全文
posted @ 2021-08-28 15:22 MyCPlusPlus 阅读(38) 评论(0) 推荐(0) 编辑
摘要: If a class does not contain virtual functions, that often indicates it is not meant to be used as a base class. When a class is not intended to be a b 阅读全文
posted @ 2021-08-27 10:14 MyCPlusPlus 阅读(50) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页