1
有了这个代码阵列成员:C++ - 初始化与骨料初始化
struct Structure {
int a;
char b[4];
};
void function() {
int a = 3;
char b[] = {'a', 'b', 'c', 'd'};
}
可使用集合初始化我初始化Structure
与a
值和b
?
我试过Structure{a, b}
,然而,让我的错误cannot initialize an array element of type 'char' with an lvalue of type 'char [4]'
如果更改'炭B []'通过'std :: array',是的。 [演示](http://coliru.stacked-crooked.com/a/8ac7cfe90b9a75e0) –
Jarod42