c++ - VS 代码给出的设置片段中的错误
问题描述
我最近开始使用 VS Code。他们的网页给出了以下从 C++ 开始的片段
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string& word : msg)
{
cout << word << " ";
}
cout << endl;
}
但是当我运行它时,它给出了以下错误:
test.cpp:9:23: error: expected ';' at end of declaration
vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
^
;
test.cpp:11:29: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const string& word : msg)
我对使用这个 IDE 以及一般使用 C++ 完全陌生。我需要安装任何库来运行它吗?
谢谢
解决方案
推荐阅读
- apache-kafka - 集群中的活动线程数少于 Apache Nifi 中的 kafka 主题分区
- python - 将列表的每个整数值转换为熊猫系列下的字符串
- eclipse - 在纸莎草纸中创建序列图的问题
- bdd - 如果我的个人工作 BDD 测试用例在标记模式下运行,为什么它们不起作用?
- java - Windows 10 缩放与绘图尺寸混淆
- javascript - 从 Dropzone.js 获取文件到 PHP 控制器
- flutter - TextField 内的后退按钮
- c# - 使用 mock 对我的 API 进行单元测试,并引用多个存储库
- python - 在 QTreeWidget 中的 QTreeWidgetItems 上使用多种高亮颜色
- python - 如何将“curl -X POST -T”转换为 python