编译错误总结

1.C++程序编译的时候报错prototype for '类名::函数名'does not match any in class'类名'

注意观察在类头文件中定义的函数类型或者参数类型与cpp文件中实现的函数或参数类型是否相同

2.unterminated comment

这句话的意思是“注释没有结束”,一般而言发生在注释标示:/* */没有写全,可能只写了前面的/*没有写后面部分。

3.c++编译错误提示[Error] name lookup of 'i' changed for ISO 'for' scoping
在VC 6 中,i的作用域范围是函数作用域,在for循环外仍能使用变量i 即: 
 
 

for (int i = 0; i < n; ++i) { 
//…… 

cout<< i<< endl; 
可以通过 
而 
for (int i = 0; i < n; ++i) { 
//…… 

int i = 5; 
则编译出错。

在DEV C++ 中,i的作用域仅限于for循环,即: 
for (int i = 0; i < n; ++i) { 
//…… 

int i = 5; 
可以通过 
而 
for (int i = 0; i < n; ++i) { 
//…… 

cout<< i<< endl; 
则编译出错。

在vs.NET 中,两种都能通过,但是若在for循环外使用i是,会给出警告。

4.error: unterminated #ifndef

1,权限问题

2,少了#endif

5.错误: expected declaration or statement at end of input

这是因为大括号的少一个,括号的个数不成对,仔细在出错的函数中查找

猜你喜欢

转载自blog.csdn.net/qq_36912408/article/details/72593544