摘要:
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 阅读全文
摘要:
,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 阅读全文
摘要:
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 阅读全文
摘要:
Consider this code: class Investment { /*...*/ }; // root class of hierarchy of investment types Investment* createInvestment(); // return ptr to dyna 阅读全文
摘要:
Consider: class Date { }; // for dates in time class Customer { public: //... // as before private: std::string name; Date lastTransaction; }; class P 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
Destructors should never emit exceptions. If functions called in a destructor may throw, the destructor should catch any exceptions, then swallow them 阅读全文
摘要:
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 阅读全文