// Program to insert node at front in linked list.//这是一个简单的链表程序,但是我不明白& newNode,newNode和newNode的//值的区别->next
void PushAtFrontLinkList(int value)
{
if(head==NULL)
{
head=tail;
}
node* newNode=new node();
newNode->data=value;
newNode->next=head;
head=newNode;
// Trying to differentiate between data contained in newNode and &newNode and newNode->next
cout<<"just new node"<<newNode<<endl; // what will be contained in newNode? cout<<"address of node"<<&newNode<<endl; // what will be contained in &newNode?
cout<<"new node next"<<newNode->next<<endl; // It will be the address of the next node?
}发布于 2014-09-18 06:00:39
newNode将包含您刚刚创建的新节点对象的地址。对于newNode-> next,它包含列表中下一个节点的地址。
请注意,在最后,newNode将是列表的头部,并且newNode->next将指向旧的头部。
发布于 2014-09-18 05:58:59
&newNode:节点在内存中的地址newNode:要操作newNode的节点-> next :下一个节点*指针。
https://stackoverflow.com/questions/25900158
复制相似问题