第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

c++的引用不知道為什么會報錯?求指教!

c++的引用不知道為什么會報錯?求指教!

C++
mrs_empress 2017-03-18 18:01:38
#include?<iostream> #include?<cstdio> using?namespace?std; typedef?int?ElemType; typedef?int?Status; const?int?n=5; struct?Node{ ????ElemType?data; ????struct?Node?*next; }Node,*LinkList; void?print_title(); void?CreateList(LinkList?&L,int?n); Status?ListDelete_first(LinkList?&L); Status?ListTraverse(LinkList?&L); int?main(){ ????int?x; ????ElemType?e; ????LinkList?L; ????CreateList(L,n); ????print_title(); ????scanf("%d",&x); ????switch(x){ ????????????case?1:ListDelete_first(L);break; ????????????case?2:ListTraverse(L);break; ????????????default:; ????} ????return?0; } void?print_title(){ ????cout<<"Delete?a?number?in?the?first,input?1;"<<endl; ????cout<<"See?all?numbers,input?2;"<<endl; ????cout<<"Quit,input?any?other?characters."<<endl; } void?CreateList(LinkList?&L,int?n){ ????LinkList?p; ????L=(LinkList)malloc(sizeof(Node)); ????L->next=NULL; ????for(i=n;i>0;--i){ ????????p=(LinkList)malloc(sizeof(Node)); ????????cin>>p->data; ????????p->next=L->next; ????????L->next=p; ????} } Status??ListDelete_first(LinkList?&L){ ????LinkList?p; ????p=L->next; ????if(!p)return?false; ????p=p->next; ????L->next=L->next->next; ????free(p); ????p=NULL; ????return?true; } Status??ListTraverse(LinkList?&L){ ????LinkList?p; ????p=L->next; ????if(!p){ ????????cout<<"empty?list!"<<endl; ????????return?false; ????} ????while(p->next){ ????????p=p->next; ????????cout<<p->data<<"\t"; ????} ????cout<<endl; ????return?true; } //error:?variable?or?field?'CreateList'?declared?void| //error:?'L'?was?not?declared?in?this?scope| //error:?expected?primary-expression?before?'int'|
查看完整描述

3 回答

已采納
?
朕日理萬機

TA貢獻(xiàn)27條經(jīng)驗 獲得超28個贊

別的,部分沒看,你目前的問題,LinkList(第10行),不是一個類型名,而是一個變量名,是一個指針類型指向了一個Node實例。而你在后面的代碼中把它當(dāng)成了一個類型名用。

查看完整回答
3 反對 回復(fù) 2017-03-18
?
鍋里煮水

TA貢獻(xiàn)4條經(jīng)驗 獲得超0個贊

linklist本身是一個指針變量,L不能定義為Linklist類型的

查看完整回答
反對 回復(fù) 2017-03-19
?
SupperMary

TA貢獻(xiàn)5條經(jīng)驗 獲得超0個贊

編譯報錯在12行,手動去掉"LinkList?&L"之后。

報錯信息“error:?variable?or?field?'CreateList'?declared?void|”沒有了,應(yīng)該是鏈表格式?jīng)]寫對(我還沒有學(xué)過鏈表,不知道具體情況)

報錯信息“error:?'L'?was?not?declared?in?this?scope|”也沒有了


把“void?CreateList(LinkList?&L,int?n);”改成“void?CreateList(int?n,LinkList?&L);”之后,報錯信息”error:?expected?primary-expression?before?'int'|“也沒有了,說明問題還是出在“LinkList &L”上,很有可能是函數(shù)格式不對。

查看完整回答
反對 回復(fù) 2017-03-18
  • 3 回答
  • 0 關(guān)注
  • 2480 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號