expected unqualified-id before ....的问题

对于这种编译错误我大体分为以下几种情况:

1.定义类时最后没有写分号

Class ****

{

...

};//就是这个分号

2.自定义函数与库函数重名(与关键字重复)

3.多写分号

例如在函数定义时

void F()//多写了

......

4.大括号使用不当

<1>

<span style="color:#333333;">int main(){

    scanf("%d",&i);
    if(i==1){
    }  
	} 
   else if(i==2){
       
}
else if(i==3){
     
}
else cout<<"wrong";
</span><span style="color:#ff6666;">}//匹配不上</span><span style="color:#333333;">
for(p=s.head->next;p;p=p->next) 
      cout<<p->data1<<" "<<p->data2<<endl;
return 0;
}</span>
<span style="font-size:18px;color:#ff0000;"><2></span>
while (true)
{
int main(int argc,char *argv[])
{
         
         return 0;
}
}<span style="color:#ff0000;">//while里包含主函数</span>
一定要分清大括号匹配与分布

5.语句放在函数体外(main与其他函数)

class ***
{
.......

};
for(int n=0;n<20;n++)
{
	
}

int main()
{
	
}
6.用了系统识别不了的或不符合格式的标识符

struct time--------------------------------------------------------------------/*时间*/
{   int hour;
	int minute;
	int second;----------------- ------------------------------------/*学生信息*/
{   char num[20];--------------- ------------------------------------/*学号*





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章