代码:
#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 时,错误消息都会显示 ...
对于以上错误,我正在更改代码块的设置... 设置> 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/