C++常见错误中英文对照表

2020-01-06 15:10:15王振洲

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 C2447: missing function header (old-style formal list?)
error C2448: '<Unknown>' : 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