Consider following code:
struct Base //in my real scenario Base class can not be changed
{
int a;
double b[10];
}
struct Child
{
Child(int aa, double bb[10]) : Base{aa} {} //This works fine
Child(int aa, double bb[10]) : Base{aa, bb} {} //this is not working
}
The second constructor of child is not working. I get the error "array must be initialized with a brace-enclosed initializer". How can I initialize b
in Child
without changing Base class (for example using vector instead of c-like array, i am not allowed to do that)
Aucun commentaire:
Enregistrer un commentaire