104. Destructors-II

Question.5

A class allocates an array and frees it with the wrong delete:

class Pool {
   Sensor* sensors;
public:
   Pool(int n) : sensors(new Sensor[n]) {}
   ~Pool() { delete sensors; }  // Wrong! Should be delete[]
};

What happens when a Pool object is destroyed?

Need Help? Refer to the Quick Guide below

Select Answer