
C++ Primer Chapter 13 (5 / 6)
文章平均质量分 80
Chen丶HC
这个作者很懒,什么都没留下…
展开
-
13.2. Copy Control and Resource Management
//Exercises Section 13.2 //Exercise 13.22: Assume that we want HasPtr to behave like a value.That //is, each object should have its own copy of the string to which the objects //point.We’ll show the d原创 2017-06-28 20:18:56 · 224 阅读 · 0 评论 -
13.3. Swap
//Exercises Section 13.3 //Exercise 13.29: Explain why the calls to swap inside swap(HasPtr&, //HasPtr&) do not cause a recursion loop. //For the swap inside function feed the library swap. //Exercis原创 2017-06-29 15:49:45 · 224 阅读 · 0 评论 -
13.4. A Copy-Control Example
//Exercises Section 13.4 //Exercise 13.33: Why is the parameter to the save and remove members //of Message a Folder&? Why didn’t we define that parameter as Folder? //Or const Folder&? //Because it h原创 2017-07-02 16:46:52 · 230 阅读 · 0 评论 -
13.5. Classes That Manage Dynamic Memory
#include #include #include using namespace std; class StrVec { public: StrVec() : elements(nullptr), first_free(nullptr), cap(nullptr) { } StrVec(const StrVec &); StrVec &operator=(const StrVe原创 2017-07-02 20:12:35 · 165 阅读 · 0 评论 -
13.1 Copy, Assign, and Destroy
/*class Sales_data { public: Sales_data(const Sales_data&); private: string bookNo; int units_sold = 0; double revenue = 0.0; }; Sales_data::Sales_data(const Sales_data&orig): bookNo(orig.bookNo原创 2017-06-27 21:43:22 · 247 阅读 · 0 评论