编译错误合集

//记录一下方便自己查错qwq

 

1.  name lookup of '变量名' changed [enabled by default]3.

如果在局部作用域嵌套了同名局部变量会出现这个错误 ,也就是说出现了重定义
2.reference to "xx" is ambiguous
定义的变量名可能是函数库里的函数名
【一个栗子】
 1
  //印象这鬼一样的排版emmmm
 #include<bits/stdc++.h>
 2 using namespace std;
 3 int a[1000];
 4 int root,maxroot,n,m,x,y,MAX,sum;
 5 int main()
 6 {
 7   ios::sync_with_stdio(false);
 8   cin>>n>>m;
 9   for(int i=1;i<=m;i++)
10   {
11     cin>>x>>y;
12     a[y]=x;
13   }
14   for(int i=1;i<=n;i++)
15   {
16   if(a[i]==0){root=i;break;
17   }
18    }cout<<root<<endl;
19   for(int i=1;i<=n;i++)
20  {
21    sum=0;
22    for(int j=1;j<=n;j++)
23   {
24    if(a[j]==i)sum++;
25    }
26    if(sum>MAX){MAX=sum;maxroot=i;    //警察蜀黍就是他!max!**为什么把max当变量会出现标题的问题呢?**因为函数库里包含max这个函数,用它会引起歧义啊淦!
27    }
28    }cout<<maxroot<<endl;
29   for(int i=1;i<=n;i++)
30 {
31 if(a[i]==maxroot)cout<<i<<" ";
32     }
33  }
View Code

3.[Error] statement has no effect

直译应该是:赋值无效!】



 4. [Error] invalid types 'int[int]' for array subscript

出现这个错误真的是很粗心呀!

应该是定义了二维数组结果用的时候写成了一维,或者反之。

 

5. [Error] variable-sized object 'dv' may not be initialized

用定义数组的时候使用变量来定义数组长度。

举个栗子: int a[i] = d[i] - d[i-1];

6. (待填坑)[Error] expected primary-expression before 'return

(暂时没有找出错误原因

posted @ 2019-06-03 10:51  QUEKI嶺冬  阅读(406)  评论(0编辑  收藏  举报
/*! Color themes for Google Code Prettify | MIT License | github.com/jmblog/color-themes-for-google-code-prettify */ .pln{color:#4d4d4c}ol.linenums{margin-top:0;margin-bottom:0;color:#8e908c}li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9{padding-left:1em;background-color:#fff;list-style-type:decimal!important;}@media screen{.str{color:#718c00}.kwd{color:#8959a8}.com{color:#8e908c}.typ{color:#4271ae}.lit{color:#f5871f}.pun{color:#4d4d4c}.opn{color:#4d4d4c}.clo{color:#4d4d4c}.tag{color:#c82829}.atn{color:#f5871f}.atv{color:#3e999f}.dec{color:#f5871f}.var{color:#c82829}.fun{color:#4271ae}} /*下面是我设置背景色,字体大小和字体*/ .cnblogs-markdown code{ background:#fff!important; } .cnblogs_code,.cnblogs_code span,.cnblogs-markdown .hljs{ font-size:16px!important; } .syntaxhighlighter a, .syntaxhighlighter div, .syntaxhighlighter code, .syntaxhighlighter table, .syntaxhighlighter table td, .syntaxhighlighter table tr, .syntaxhighlighter table tbody, .syntaxhighlighter table thead, .syntaxhighlighter table caption, .syntaxhighlighter textarea { font-size: 16px!important; } .cnblogs_code, .cnblogs_code span, .cnblogs-markdown .hljs{ font-family:consolas, "Source Code Pro", monaco, monospace !important; } //以上是代码高亮 /* 文字特效 */