CS计算机代考程序代写 // from: https://en.cppreference.com/w/cpp/language/aggregate_initialization
// from: https://en.cppreference.com/w/cpp/language/aggregate_initialization
#include
#include
struct S {
int x;
struct Foo {
int i;
int j;
int a[3];
} b;
};
union U {
int a;
const char* b;
};
int main()
{
S s1 = { 1, { 2, 3, {4, 5, 6} } };
S s2 = { 1, 2, 3, 4, 5, 6 }; // same, but with brace elision
S s3{ 1, {2, 3, {4, 5, 6} } }; // same, using direct-list-initialization syntax
S s4{ 1, 2, 3, 4, 5, 6 }; // error in C++11: brace-elision only allowed with equals sign
// okay in C++14
int ar[] = { 1,2,3 }; // ar is int[3]
// int ab[](1, 2, 3); // (C++20) ab is int[3]
// char cr[3] = {‘a’, ‘b’, ‘c’, ‘d’}; // too many initializer clauses
char cr[3] = { ‘a’ }; // array initialized as {‘a’, ‘