我试图用c ++学习链表;我的代码看起来像这样
#include <iostream>
#include <string>
using namespace std;
struct node{
int number;
node *next;
};
struct zoznam{
node *head=NULL;
node *tail=NULL;
};
void insertAsFirst(node *&head,node *&last, int number){
node *tmp = new node;
tmp->number = number;
tmp->next=NULL;
head=tmp;
last=tmp;
}
void insertValues( node *&head , node *&last, int number){
if(head==NULL){
insertAsFirst(zoznam->head,zoznam->tail,number);
}else{
node *tmp = new node;
tmp->number=number;
tmp->next=NULL;
last->next=tmp;
//last=tmp;
}
}
int main()
{
for( int i = 0; i < 10; i++){
insertValues(zoznam->head,zoznam->tail,i);
}
node *current=zoznam->head;
while(current!=NULL){
cin<<current->number << endl;
current=current->next;
}
return 0;
}
在' - &gt;'之前预期的主要表达式令牌|
作为c ++的新手,我不知道错误意味着什么,我怎么能解决这个问题,我试图检查它但却一无所获。感谢