If I delete an instance of StructAB using a StructA pointer, will it also delete the contents of StructB?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
struct StructA {
int A
};
struct StructB {
int B
};
struct StructAB :public StructA, StructB {
};
int main() {
StructA ** list = new StructA *[1];
list[0] = new StructAB;
delete StructA[0];
delete[] StructA;
//all memory released?
};
... What about in this case?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
struct StructA {
int A
};
struct StructAB : public A {
int B
};
int main() {
StructA ** list = new StructA *[1];
list[0] = new StructAB;
delete StructA[0];
delete[] StructA;
//all memory released?
};