错误:无效的初始值设定
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.
在此, tv
和init
是较早定义的变量。
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.
在这里, 元素的顺序与声明中元素的顺序完全相同 。
错误:无效的初始值设定