For an array based implementation, wouldn't it just be "delete[] myarray", or would it be more complicated?
Is it necessary to delete each individual element in the queue or does that just suffice?
Could someone give me an example if it is?
Printable View
For an array based implementation, wouldn't it just be "delete[] myarray", or would it be more complicated?
Is it necessary to delete each individual element in the queue or does that just suffice?
Could someone give me an example if it is?
The easiest thing to do is just hold an std::vector or std::array inside your queue, which one depending if the max queue size is known compile time or runtime. No destructor needed in that case.
It does not depend on a kind of collection (queue or array); it only depends on a lifetime of items. If the item is pointer and the queue owns items, then you should delete each individual item. You could use any smart pointer to automate the deletion of items, e.g. share_ptr.
You'd think that after a week of waiting, the guy would have said something if he'd wanted more input or a thread bumped.