错误:无效的初始值设定_g ++:抱歉,未实现:不支持非平凡的指定初始值设定项...

错误:无效的初始值设定

g++ (version g++ (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)) report:

g ++(g ++版本g++ (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1) )报告:

$ g++ -std=c++11 solution.cpp -o sol

solution.cpp: In function ‘int main()’:
solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported
     Stat init_stat {.depth = 0, .moves = tv, .vec = init};
                                                         ^
solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported
solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported
make: *** [all] Error 1

For one program. The program is like this:

对于一个程序。 该程序是这样的:

First, declare a struct

首先,声明一个结构

struct Stat {
    vector<int> vec;
    int depth;
    vector<pair<int, int>> moves;
};

Later part, define a Stat struct object with:

在后面的部分中,使用以下命令定义Stat结构对象:

Stat init_stat {.depth = 0, .moves = tv, .vec = init};

Here, tv and init are variables defined earlier.

在此, tvinit是较早定义的变量。

The compiler reports the above error.

编译器报告上述错误。

To make is work with g++ 4.8.1:

make适用于g ++ 4.8.1:

Define a Stat struct object as:

将Stat结构对象定义为:

Stat init_stat { .vec = init, .depth = 0, .moves = tv};

Here, the order of elements are exactly the same as the order of the elements in the declaration.

在这里, 元素的顺序与声明中元素的顺序完全相同

Answered by anonymous.
匿名回答。

翻译自: https://www.systutorials.com/g-sorry-unimplemented-non-trivial-designated-initializers-not-supported/

错误:无效的初始值设定

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值