c++ - 为什么代码块显示错误?

标签 c++ compiler-errors codeblocks

代码:

#include<map>
#include<vector>
#include<iostream>

using namespace std; 

int main() 
{ 
    map<int, int> mp1, mp2; 
    mp1.insert({ 1, 2 }); 
    cout << "The max size of mp1 is " << mp1.max_size(); 
    cout << "\nThe max size of mp2 is " << mp2.max_size(); 
    return 0; 
}

每次我运行 map 时,错误消息都会显示 ...
enter image description here

对于以上错误,我正在更改代码块的设置... 设置> GNU GCC编译器>编译器标志> g++遵循C++ 11 ISO C++语言标准[-std = c++ 11]
但是这次也显示了相同的错误

我应该怎么做?

最佳答案

#include<map>
#include<vector>
#include<iostream>

using namespace std; 

int main() 
{ 
    map<int, int> mp1, mp2; 
    mp1.insert({ 1, 2 }); 
    cout << "The max size of mp1 is " << mp1.max_size(); 
    cout << "\nThe max size of mp2 is " << mp2.max_size(); 
    return 0;

是否就是所有代码(如果是),最后都缺少},并且解释器应该给您一个错误。如果没有,请通过完整的代码部分。

干杯

关于c++ - 为什么代码块显示错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62233080/

相关文章:

c++ - Xcode 9 开始在 C++ 中构建部分模板特化

java - 错误: cannot find symbol for correctly used methods (I think)

java - 有人可以帮我解决我的代码错误吗?

c++ - GL/glx 没有正确链接

opengl - 对 `glewInit@0' 的 undefined reference

c - 可执行文件(用 C 语言编写)是否存在某种内存限制才能正常运行?

c++ - 从 Linux 移植到 Windows,tm.sys

c++ - SSE 中高效的 min() 函数

c++ - Microsoft 对象,Release() 函数返回值?

ios - 从静态库初始化对象时,在构建过程中发生编译错误