Assuming we have :
class A {
protected:
int* iArr;
float *fArr;
public:
A(int* iArr,float *fArr);
~A();
}
class B : public A {
private:
double *dArr;
public:
B(int* iArr,float *fArr,double *dArr);
~B();
}
my intuation was that it would only invoke B's destructor but when i ran it on Visual C++ i saw that when destructing an instance of B it calls both A and then B destructor.
What is the correct way to write destructor in a derived class then? do i always need to assume parent class would take care of deleting everything but what only the derived class have?
Edit:
if it is so, then what if the child extending parent class only with overriding functions,does that mean that i leave the child's destructor empty?
what if i want to change that? i mean what if i want only child destructor to be called? is there a way to do that?