【发布时间】:2014-11-08 02:32:53
【问题描述】:
我的节点包含一个 int 和一个字符串变量,我尝试使用二叉搜索树。代码如下:
struct node{
int a;
string members[5];
};
int main(){
node * root = NULL;
root = (node*)malloc(sizeof(node));
root->members[0] = "aaaaa";
return 0;
}
当然,我的代码并不完全一样,我把它写在 main 中是因为我只想展示问题所在。它给了我“访问违规写作位置”。我尝试使用“新节点();”而不是 malloc 并没有发生。为什么会这样?
【问题讨论】:
标签: c++ c string tree binary-search-tree