【发布时间】:2014-02-18 19:59:39
【问题描述】:
如果我创建如下节点
struct node
{
char *ptr = (char *)malloc(sizeof(char));
}*current;
void main()
{
node *temp = new node();
current = temp;
}
上面的代码会自动将current->ptr 设置为temp->ptr 指向的位置吗?
【问题讨论】:
-
这是完全无效的 C++ 代码。请通过具有严格警告和错误检查的编译器运行它,并使用更正的代码更新您的问题。
-
你的代码不会做这些事情,因为它不会编译。
-
抱歉,弄错了。立即编辑!
标签: c++ pointers data-structures malloc nodes