I want to initialize an array of pointers to a base class through an initializer list, giving it addresses of objects of derived classes.
King king{square};
Queen queen{square};
Rook rook{square};
Piece* pieces[] = {&king, &queen, &rook};
Ideally, I'd like having
Piece* pieces[] = {
&King{square},
&Queen{square},
&Rook{square}
};
But I can't use addresses of temporary objects.
Is there a neat way to write the constructors directly inside the initializer list?