概述
Exercise 13.28: Given the following classes, implement a default constructor and the necessary copy-control members.
(a) class TreeNode { private: std::string value; int count; TreeNode *left; TreeNode *right; }; (b) class BinStrTree { private: TreeNode *root; };
如下類別,請試著實作出它們的預設建構器(default constructor)和必要的拷貝控制成員。
TreeNode.h
#include<string>
#include"TreeNode.h"
#include"BinStrTree.h"
using namespace std;
int main() {
TreeNode tn,tn1("孫守真"),tn2(string("阿彌陀佛"));
tn = tn1;
TreeNode tn3(tn2);
tn = tn2;
tn1 = tn3;
BinStrTree bst("妙音如來"),bst1(bst),bst2,bstp(new TreeNode(tn3));
bst2 = bst;
bstp = bst2;
}
BinStrTree.h
#include<string>
#include"TreeNode.h"
#include"BinStrTree.h"
using namespace std;
int main() {
TreeNode tn,tn1("孫守真"),tn2(string("阿彌陀佛"));
tn = tn1;
TreeNode tn3(tn2);
tn = tn2;
tn1 = tn3;
BinStrTree bst("妙音如來"),bst1(bst),bst2,bstp(new TreeNode(tn3));
bst2 = bst;
bstp = bst2;
}
.cpp
#include<string>
#include"TreeNode.h"
#include"BinStrTree.h"
using namespace std;
int main() {
TreeNode tn,tn1("孫守真"),tn2(string("阿彌陀佛"));
tn = tn1;
TreeNode tn3(tn2);
tn = tn2;
tn1 = tn3;
BinStrTree bst("妙音如來"),bst1(bst),bst2,bstp(new TreeNode(tn3));
bst2 = bst;
bstp = bst2;
}
https://github.com/oscarsun72/prog1-C-Primer-5th-Edition-s-Exercises/tree/exercise13_28a/prog1
臉書直播實境秀
C++自修入門實境秀 542 重新譯撰 《C++ Primer 5th》
13.2 拷貝控制與資源管理 13.2.2. Defining Classes That Act Like Pointers Defining a Reference-Counted Class~ 練習13.28
上一集:
https://www.facebook.com/100003034306665/videos/2659180040859780
下一集:
全部:http://bit.ly/2NoA2ID 原檔下載:http://bit.ly/2Ixe2Vc
課文: http://bit.ly/2FIHV57
http://bit.ly/2mttmfa(第二篇)
第10-11章: http://bit.ly/2MuPmiZ
章12: http://bit.ly/2Rw53sH
重譯12章:http://bit.ly/2V8UgZ7
http://bit.ly/2G2fPSg (docx)
重譯11章:http://bit.ly/39P7HRU
第三篇:http://bit.ly/2UaFbDY
第三篇13章:http://bit.ly/33mh49y
https://play.google.com/books/reader?id=J1HMLyxqJfgC&pg=GBS.PT951.w.0.0.0.0.1
講義下載:
http://bit.ly/2khF8Ic (全部)
程式碼:
https://github.com/oscarsun72/prog1
緣起:http://bit.ly/2XwHOUH
最后
以上就是粗犷百褶裙为你收集整理的C++ Primer 5th Edition Exercises(練習題)13.28的全部内容,希望文章能够帮你解决C++ Primer 5th Edition Exercises(練習題)13.28所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复