So I essentially want to do this:
struct A {
A *children[10];
};
However, when I do this and create a destructor such as:
virtual ~A() {
for (A *child: children) {
delete child;
}
}
I get a segmentation fault and I'm not sure why. So how can I accomplish holding a list of A within A using an STL class so I don't have to worry about new/delete? I tried vector and get an "incomplete type" error.
Aucun commentaire:
Enregistrer un commentaire