In order to initialize an array in the class member initialization list you need to use curly braces like you would if you were initializing an array in a function.
Thus if you wanted to initialize the first and second element of the array you would need to use at least
A() : arrB{{1,2}, {3,4}} {}
as the first set ({1,2}) says make arrB[0] a B with x and y initialized to 1 and 2 respectively. The second set ({3,4}) says make arrB[1] a B with x and y initialized to 3 and 4 respectively.
You do have to do one thing though in order to make this work. You either need to make B and aggregate by making x and y public, or you can provide a constructor for B that takes to values. Doing that lets you have either
class A{
class B{
public:
int x, y;
};
B arrB[10];
public:
A() : arrB{{}, {3,4}} {}
};
int main() {
A a;
}
or
class A{
class B{
int x, y;
public:
B() : x(), y() {} // need this so default instances are value initialized (zeroed in this case)
B(int x, int y) : x(x), y(y) {}
};
B arrB[10];
public:
A() : arrB{{}, {3,4}} {}
};
int main() {
A a;
}
arrB{{1,2},{3,4},{},{},{},{},{},{},{},{}}orarrB{{1,2},{3,4}}however rest of the elements gets random values and it must be a struct or public x,ystruct { int x, y; };