와 배열 구성원 초기화 :C++ -이 코드로 집계 초기화
struct Structure {
int a;
char b[4];
};
void function() {
int a = 3;
char b[] = {'a', 'b', 'c', 'd'};
}
내가 집계 초기화를 사용 a
의 값으로 Structure
및 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