C++ Eclipse:二叉搜索树节点>数据=变量似乎不起作用
C++ Eclipse: Binary Search Tree node->data = variable doesn't seem to work
构建成功,但运行时停止在
节点>数据 = 出价;
在以下函数中。因此,输出成功打印到"加载CSV文件888"cout语句。我不确定是什么阻止它运行该代码。
void BinarySearchTree::Insert(Bid bid) {
// FIXME (2a) Implement inserting a bid into the tree
cout << "Loading CSV file 333" << endl;
Node* node = root;
cout << "Loading CSV file 888" << endl;
node->data = bid;
cout << "Loading CSV file 777" << endl;
if (root == NULL){
//root->data = bid;
//root->left = 0;
//root->right = 0;
root = node;
node->left = NULL;
node->right = NULL;
cout << "Loading CSV file 444" << endl;
}
else
{
cout << "Loading CSV file 666" << endl;
Node* cur;
cur = root;
while (cur != NULL){
if (strToDouble2(node->data.bidId) < strToDouble2(cur->data.bidId)){
if (cur->left == NULL){
cur->left = node;
cur = NULL;
}
else{
cur = cur->left;
}
}
else
if (cur->right == 0){
cur->right = node;
cur = NULL;
}
else{
cur = cur->right;
}
node->left = NULL;
node->right = NULL;
cout << "Loading CSV file 5555" << endl;
}
}
}
因为树是空的,所以root
是空指针,自node = root;
年以来node
也是如此。
从存储要插入根节点的值开始是非常奇怪的。
如果要添加节点,代码应显示new Node
某处,并且插入的值应位于该节点中。
弄清楚在哪里创建它作为练习。
相关文章:
- 尝试通过OCI例程从Oracle获取blob数据,但出现错误:ORA-01008:并非所有变量都绑定
- 我可以在 C++ 中将数据成员/变量从其定义之外添加到结构中吗?
- 从模板创建通用打印函数,以打印基元数据类型变量的值
- 如何在变量中插入多种不同长度的数据类型?
- 如果变量数据包含大于 vector 所有元素的整数,则仅在视觉工作室上接收"矢量下标超出范围"?
- 逐行读取文件,并将数据插入变量和数组中
- 如何使用C++中可以具有多种数据类型的单个变量
- C++ 成员不是变量,而只是数据类型的名称吗?
- 指针数据类型变量如何包含对象?
- 将数据从 SQLite 数据库保存到变量中
- 如何从excel文件中读取数据并存储到变量中?
- 如果一个变量在它之前释放了另一个(相同的数据类型)变量,如何将其分配给内存?
- 如何有效地实现将向量的数据分配给多个变量?
- 返回实例变量的c++方法可以访问变量中的数据,但不能更改它,但在编译时不会生成错误
- C++ Eclipse:二叉搜索树节点>数据=变量似乎不起作用
- C++运算符重载和访问私有数据变量
- 如何从输入文件C++的行读取多个数据变量
- "数据变量"是什么意思?
- 区分指针和数据变量
- 将文件数据变量存储在维度数组中