// 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?


}

最佳答案

newNode将包含您刚创建的新节点对象的地址。至于newNode-> next,它包含列表中下一个节点的地址。

请注意,最后,newNode将成为列表的头部,而newNode-> next将指向旧的头部。

关于c++ - 链表中节点,节点和节点之间的区别,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25900158/

10-11 05:00