我正在尝试复制一本关于学习c++的教科书中解释的代码。最简单的例子如下所示。但是它并没有像预期的那样编译。
#include<vector>
using namespace std;
struct Storage
{
vector<int> data;
};
Storage GetStorage(vector<int> params)
{
return Storage{ .data=params};
}Intellisense给我返回了这个错误:
Storege{(<error-type>)<error-constant>}
expected an expression C/C++(29)发布于 2021-03-28 21:39:20
必须将语言版本设置为C++20,指定的初始值设定项才能工作。在visual studio上,必须在其他编译器上启用标志/std:c++latest和-std=c++20。
https://stackoverflow.com/questions/66842001
复制相似问题