c++代码错误

[复制链接]
查看11 | 回复3 | 2009-7-26 21:48:26 | 显示全部楼层 |阅读模式
#include
int main()
{
const int black = 0;
const int white = 1;
const int pink = 2;
const int gray = 3;
const int blue = 4;
const int red = 5;
const int indigo = 6;
const int yellow = 7;
const int "D-I-S-K,desk" = 8;
const int "G-E-E-P,jeep" = 9;
const int "Do you understand?" = 10;
const int "Are you ready?" = 11;
const int "Go Go!" = 12
const int "THIS IS THE AMERICA inthe VOA Special ENGLISH" = 13;
int TheWord;
TheWord = "Do you understand?";
if (TheWord == black || TheWord == blue || TheWord == red || TheWord == indigo)
std::cout << "\nI love the color!\n";
if (TheWord == white || TheWord == gray || TheWord == pink || TheWord == yellow)
std::cout << "\nI hate the color!\n";
else
std::cout << "\nThat`s what my dad say all day and all night. Close in a hurry! \n";
return 0;
}
error C2598: linkage specification must be at global scope
warning C4518: 'const int ' : storage-class or type specifier(s) unexpected here; ignored
warning C4502: 'linkage specification' requires use of keyword 'extern' and must precede all other specifiers
error C2537: 'D-I-S-K,desk' : illegal linkage specification
error C2513: 'int' : no variable declared before '='
error C2598: linkage specification must be at global scope
warning C4518: 'const int ' : storage-class or type specifier(s) unexpected here; ignored
warning C4502: 'linkage specification' requires use of keyword 'extern' and must precede all other specifiers
error C2537: 'G-E-E-P,jeep' : illegal linkage specification
error C2513: 'int' : no variable declared before '='
error C2598: linkage specification must be at global scope
warning C4518: 'const int ' : storage-class or type specifier(s) unexpected here; ignored
warning C4502: 'linkage specification' requires use of keyword 'extern' and must precede all other specifiers
error C2537: 'Do you understand?' : illegal linkage specification
error C2513: 'int' : no variable declared before '='
error C2598: linkage specification must be at global scope
warning C4518: 'const int ' : storage-class or type specifier(s) unexpected here; ignored
warning C4502: 'linkage specification' requires use of keyword 'extern' and must precede all other specifiers
error C2537: 'Are you ready?' : illegal linkage specification
error C2513: 'int' : no variable declared before '='
error C2598: linkage specification must be at global scope
warning C4518: 'const int ' : storage-class or type specifier(s) unexpected here; ignored
warning C4502: 'linkage specification' requires use of keyword 'extern' and must precede all other specifiers
error C2537: 'Go Go!' : illegal linkage specification
error C2513: 'int' : no variable declared before '='
error C2143: syntax error : missing ';' before 'const'
error C2440: '=' : cannot convert from 'char [19]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.
无必要部分已删除,

回复

使用道具 举报

千问 | 2009-7-26 21:48:26 | 显示全部楼层
#include 后面加一句 using name space std;const int "D-I-S-K,desk" = 8;const int "G-E-E-P,jeep" = 9;const int "Do you understand?" = 10;const int "Are you ready?" = 11;const int "Go Go!" = 12const int "THIS IS THE AMERICA inthe VOA Special ENGLISH" = 13;命名规则不对int TheWord;TheWord = "Do you understand...
回复

使用道具 举报

千问 | 2009-7-26 21:48:26 | 显示全部楼层
完全错了...
回复

使用道具 举报

千问 | 2009-7-26 21:48:26 | 显示全部楼层
思路错误,语法错误。建议用STL的map容器...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行