I have 2 classes:
class A
{
public:
char * x;
char * y;
char * z;
A();
~A();
}
class B: public A
{
public:
char * o;
B();
~B();
}
I want to delete[] x, y, and z in class B’s destructor (And yes, A’s constructor does properly allocate x, y, and z). The code will compile fine, but upon execution it will crash. The properties are public, so inherited traits should be able to free up some memory for me, right?
I called A’s constructor/destructor as well as B’s, so that causes several issues on how I coded it, notably a severe memory leak. Thanks for all of the help guys, I just was confused due to someone telling me that onle constructors were inherited.