We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class TreeNode在习题13.28(a)中被定义为: Exercise 13.28 defines class TreeNode as follow:
class TreeNode
class TreeNode { private: std::string value; int count; TreeNode* left; TreeNode* right; };
但是在 ex13_28.h 中class TreeNode却被定义为: While class TreeNode defined in ex13_28.h is :
class TreeNode { ... ... ... private: std::string value; int* count; // 私有成员 count 类型从 int 变为 int* // Type of private memeber count changed from int to int* TreeNode* left; TreeNode* right; };
是当时疏忽了吗? 重新看了一下,感觉这个count是给TreeNode记数的,这样的话,count确实应该是int*类型,可能是书漏印了?
count
TreeNode
int*
The text was updated successfully, but these errors were encountered:
重新看了一下,感觉这个count是给TreeNode记数的,这样的话,count确实应该是int*类型,可能是书漏印了?
是的,这道题至今都让我很矛盾。请见:https://www.douban.com/group/topic/71666445/
我的答案给出了我觉得合理的写法。。。
Sorry, something went wrong.
int 还是 int* 这两种定义都是可以的,关键看怎么定义~TreeNode()和拷贝赋值; 当然 int* 的定义是跟着书本走的。最主要保证一点当count变量为0时或者指向的内容为0时析构对象, 拷贝赋值时+1.
会不会有可能是节点序号?序列化的时候需要编号,不过那和本节的内容就不太相关了
No branches or pull requests
class TreeNode
在习题13.28(a)中被定义为:Exercise 13.28 defines
class TreeNode
as follow:但是在 ex13_28.h 中
class TreeNode
却被定义为:While
class TreeNode
defined in ex13_28.h is :是当时疏忽了吗?
重新看了一下,感觉这个
count
是给TreeNode
记数的,这样的话,count
确实应该是int*
类型,可能是书漏印了?The text was updated successfully, but these errors were encountered: