Question.7
A base pointer deletes a derived object:
class IDriver {
public:
virtual void init() = 0;
// No virtual destructor!
};
class UART : public IDriver {
uint8_t* buf;
public:
UART() : buf(new uint8_t[64]) {}
~UART() { delete[] buf; }
void init() override {}
};
IDriver* d = new UART();
delete d;What happens?