小编Gig*_*ion的帖子

错误:C++ 要求所有声明都有类型说明符

我是 C++ 新手,我一直在读这本书。我读了几章,想到了自己的想法。我尝试编译下面的代码,但出现以下错误:

||=== 构建:密码调试(编译器:GNU GCC 编译器)===| /Users/Administrator/Desktop/AppCreations/C++/Password/Password/main.cpp|5|错误:C++ 需要所有声明的类型说明符| ||=== 构建失败:1 个错误,0 个警告(0 分钟,2 秒)===|。

我不明白代码有什么问题,有人可以解释一下有什么问题以及如何修复它吗?我读了其他帖子,但我无法理解。

谢谢。

#include <iostream>

using namespace std;

main()
{
    string password;
    cin >> password;
    if (password == "Lieutenant") {
        cout << "Correct!" << endl;
    } else {
        cout << "Wrong!" << endl;
    }

}
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors codeblocks specifier

6
推荐指数
2
解决办法
6万
查看次数

标签 统计

c++ ×1

codeblocks ×1

compiler-errors ×1

specifier ×1