30. Dynamic Memory Allocation-i

Question.1

A developer creates a Sensor object using malloc in a C++ project:

Sensor* s = (Sensor*)malloc(sizeof(Sensor));
s->init();

Another developer uses new:

Sensor* s = new Sensor();

What critical difference does new provide over malloc?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!