I've been given a struct that I cannot modify. Is it possible to provide my destructor and use it instead of the given one? Or maybe define my struct and then typecast it when needed? Inheritance is also an option, but didn't manage to skip call of parent destructor.
//Given struct
struct TA {
~TA() {
delete m_L;
delete m_R;
}
TA* m_L;
TA* m_R;
};
//What i need
struct TB {
~TB() {
if (m_L) m_L->destroy();
if (m_R) m_R->destroy();
}
void destroy() {
if (!--nRefernece) delete this;
}
int nRefernece;
TB* m_L;
TB* m_R;
};