对照:(编译错误)未定义的标识符 xxx
解决方案:
(1) 如果 xxx 为 cout、cin、scanf、printf、sqrt 等,则程序中包含头文件有误
(2) 未定义变量、数组、函数原型等,注意拼写错误或区分大小写。
error C2078: too many initializers
中文对照:(编译错误)初始值过多
解决方案:一般是数组初始化时初始值的个数大于数组长度,例如“int b[2]={1,2,3};”
error C2082: redefinition of formal parameter 'xxx'
中文对照:(编译错误)重复定义形式参数 xxx
解决方案:函数首部中的形式参数不能在函数体中再次被定义
error C2084: function 'xxx' already has a body
中文对照:(编译错误)已定义函数 xxx
解决方案:在 VC++早期版本中函数不能重名,6.0版本中支持函数的重载,函数名可以相同但参数不一样
error C2086: 'xxx' : redefinition
中文对照:(编译错误)标识符 xxx 重定义
解决方案:变量名、数组名重名
error C2087: '
' : missing subscript
中文对照:(编译错误)下标未知
解决方案:一般是定义二维数组时未指定第二维的长度,例如“int a[3][];”
error C2100: illegal indirection
中文对照:(编译错误)非法的间接访问运算符“”
解决方案:对非指针变量使用“”运算
error C2105: 'operator' needs l-value
中文对照:(编译错误)操作符需要左值
解决方案:例如“(a+b)++;”语句,“++”运算符无效
error C2106: 'operator': left operand must be l-value
中文对照:(编译错误)操作符的左操作数必须是左值
解决方案:例如“a+b=1;”语句,“=”运算符左值必须为变量,不能是表达式
error C2110: cannot add two pointers
中文对照:(编译错误)两个指针量不能相加
解决方案:例如“intpa,pb,*a;a=pa+pb;”中两个指针变量不能进行“+”运算
error C2117: 'xxx' : array bounds overflow
中文对照:(编译错误)数组 xxx 边界溢出
解决方案:一般是字符数组初始化时字符串长度大于字符数组长度,例如“char str[4] = "abcd";”
error C2118: negative subscript or subscript is too large
中文对照:(编译错误)下标为负或下标太大
解决方案:一般是定义数组或引用数组元素时下标不正确
error C2124: divide or mod by zero
中文对照:(编译错误)被零除或对 0 求余
解决方案:例如“int i = 1 / 0;”除数为 0
error C2133: 'xxx' : unknown size
中文对照:(编译错误)数组 xxx 长度未知
解决方案:一般是定义数组时未初始化也未指定数组长度,例如“int a[];”
error C2137: empty character constant。
中文对照:(编译错误)字符型常量为空
解决方案:一对单引号“''”中不能没有任何字符
error C2143: syntax error : missing 'token1' before 'token2'
error C2146: syntax error : missing 'token1' before identifier 'identifier'
中文对照:(编译错误)在标识符或语言符号 2 前漏写语言符号 1
解决方案:可能缺少“{”、“)”或“;”等语言符号
error C2144: syntax error : missing ')' before type 'xxx'
中文对照:(编译错误)在 xxx 类型前缺少‘)’
解决方案:一般是函数调用时定义了实参的类型
error C2181: illegal else without matching if
中文对照:(编译错误)非法的没有与 if 相匹配的 else
解决方案:可能多加了“;”或复合语句没有使用“{}”
error C2196: case value '0' already used
中文对照:(编译错误)case 值 0 已使用
解决方案:case 后常量表达式的值不能重复出现
error C2296: '%' : illegal, left operand has type 'float'
error C2297: '%' : illegal, right operand has type 'float'
中文对照:(编译错误)%运算的左(右)操作数类型float,这是非法的
解决方案:求余运算的对象必须均为int类型,应正确定义变量类型或使用强制类型转换
error C2371: 'xxx' : redefinition; different basic types
中文对照:(编译错误)标识符 xxx 重定义;基类型不同
解决方案:定义变量、数组等时重名
error C2440: '=' : cannot convert from 'char [2]' to 'char'
中文对照:(编译错误)赋值运算,无法从字符数组转换为字符
解决方案:不能用字符串或字符数组对字符型数据赋值,更一般的情况,类型无法转换
error C2448: '
' : function-style initializer appears to be a function definition
中文对照:(编译错误)缺少函数标题(是否是老式的形式表?)
解决方案:函数定义不正确,函数首部的“()”后多了分号或者采用了老式的 C 语言的形参表
error C2450: switch expression of type 'xxx' is illegal
中文对照:(编译错误)switch 表达式为非法的 xxx 类型
解决方案:switch 表达式类型应为 int 或 char
error C2466: cannot allocate an array of constant size 0
中文对照:(编译错误)不能分配长度为 0 的数组
解决方案:一般是定义数组时数组长度为 0
error C2601: 'xxx' : local function definitions are illegal
中文对照:(编译错误)函数 xxx 定义非法
解决方案:一般是在一个函数的函数体中定义另一个函数
error C2632: 'type1' followed by 'type2' is illegal
中文对照:(编译错误)类型 1 后紧接着类型 2,这是非法的
解决方案:例如“int float i;”语句
error C2660: 'xxx' : function does not take n parameters
中文对照:(编译错误)函数 xxx 不能带 n 个参数
解决方案:调用函数时实参个数不对,例如“sin(x,y);”
error C2664: 'xxx' : cannot convert parameter n from 'type1' to 'type2'
中文对照:(编译错误)函数 xxx 不能将第 n 个参数从类型 1 转换为类型 2
解决方案:一般是函数调用时实参