【发布时间】:2014-02-19 13:35:39
【问题描述】:
struct node
{
char *ptr = (char *)malloc(frames*sizeof(char));
}*start,*current;
然后我分配了等于node 的内存来启动。
[...]//Assigned values to start node.
current = start;//Current points to start
node *temp = new node();//temp will point a newly created node
*temp = *current;// COPYING VALUES OF CURRENT TO TEMP
[...]
我想创建一个新节点,让temp 指向它并将current 的值(这里的电流指向开始)复制到 temp。
但是,这是在创建临时点 current(此处为 start)。
沮丧的。我哪里错了?
【问题讨论】:
-
这是什么语言?当然不是 C ...
-
在 c++ 中做,但我看不出有任何理由让它不在 c 中运行
-
@SrujanBarai 你知道C 中没有
new,对吧?而且你不能在这样的结构声明中调用函数?不确定你是否可以在 C++ 中做到这一点。 -
结构中的函数调用是工作伙伴。 c++