【发布时间】:2019-12-23 11:02:47
【问题描述】:
// Node
struct Node
{
int val;
string color;
Node* left_child;
Node* right_child;
};
为什么下面的代码不起作用?
Node* node = new Node();
Node* &test_node = node->left_child;
test_node = new Node();
test_node->val = 1;
test_node = test_node->left_child; // this
test_node = new Node();
test_node->val = 2;
为什么 test_node 不能指向标记位置上的父节点?
【问题讨论】:
标签: c++ pointers reference binary-tree