31. Dynamic Memory Allocation-ii

Question.3

A developer creates a driver object with malloc:

class I2C_Driver {
   uint8_t addr;
public:
   I2C_Driver(uint8_t a) : addr(a) { init_hw(); }
   ~I2C_Driver() { deinit_hw(); }
};

I2C_Driver* drv = (I2C_Driver*)malloc(sizeof(I2C_Driver));

What is wrong?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!