I would like to know why the following code is wrong to the compiler :
struct foo {
int a;
vector<foo> b;
};
int main() {
foo c = foo{1, vector<foo>{1, vector<foo>{1}}};
}
whereas it compiles with this one:
foo c = foo{1, vector<foo>{1}};
Is that because this kind of nested structure construction is not supported or I am doing it all wrong ?
Aucun commentaire:
Enregistrer un commentaire