I've a class named as "Menu", this class has an array of pointers to Objects of class "MenuItem". First three relevant lines of Menu class looks like:
class Menu
{
MenuItem *items[5];
In the Constructor of Menu class I'm creating items as:
for(int i=0; i<nItems; i++)
{
items[i] = new MenuItem(titles[i],...); //with all necessary parameters
In the destructor of Menu class I'm deleting items as:
~Menu()
{
for(int i=0; i<nItems; i++)
delete items[i];
Problem: My problem is that when I call this destructor I got an Error Debug Assertion Failed!. Except this destructor Everything works perfectly fine. If I don't call this destructor there is no error. I want to know how to tackle this problem? I want to delete this array, so that my memory gets clean.
nItems=4std::vectorand/orstd::unique_ptr, which are specifically designed to manage memory correctly, rather than juggling pointers and hoping for the best?