很难理解这个节点是如何创建的,您可以逐步写出这组代码实际在做什么以及它们代表什么动作?创建并向链接列表添加新节点
void list::create_node(int value)
{
struct node *temp;// Please write in words the meaning of this statement
temp = new(struct node);// is this a dynamic node?)
temp->info = value;// is this value being assigned to this node?
if (last == NULL)// what is this set of code testing??
{
last = temp;// who is this last; the node which has been created?
temp->next = last; // is the node pointing to itself being only one node?
}
else
{
temp->next = last->next;(((// What is this statement saying?
last->next = temp;// What is this statement saying?
last = temp;// What is this statement saying?
}
}
我相信你至少明白这段代码的一行。请确切地确定你不了解的内容。 –
我在代码旁边贴出了我的疑惑。 if语句节点的WH部分是“LAST” – ahmed
这段代码已经几乎用普通英语了。 – bereal