问题描述
所以我有一个未保存的程序,这是它的样子
#include <iostream>
#include <string>
#include <vector>
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 << '\n';
cout << "Hello world" << "\n";
}
一旦保存,就会发生这种情况
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<string> msg{"Hello","and the C++ extension!"};
for (const string& word : msg) {
cout << word << " ";
}
cout << '\n';
cout << "Hello world"
<< "\n";
return 0;
}
到目前为止,我知道我唯一已应用的样式是Google样式指南,该样式在今天早些时候有效,但现在它正在执行。我也收到此错误first.cpp:8:23: error: expected ';' at end of declaration vector<string> msg{"Hello","and the C++ extension!"};
解决方法
尝试仅使用