【发布时间】:2021-12-13 01:38:06
【问题描述】:
在第 15 行出现“预期表达式”错误。不知道它需要什么以及如何解决。
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main() {
int q;
cin >> q;
string command, task;
int day;
int index = 1;
vector<int> m_Lenght;
m_Lenght = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31}; //<-- Here in line 15
return 0;
}
【问题讨论】:
-
使用至少支持 C++ 11 的编译器。
-
你的意思是 m_Length 而不是 m_Lenght?
-
将两行改为:
vector<int> m_Lenght{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31};,或改为:m_Lenght = vector<int>{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31}; -
@Eljay 你的评论没有意义。
-
@Eljay 这两个选项都不起作用。
标签: c++ vector initialization assignment-operator stdinitializerlist