I have the following code:
class MyList
{
    private:
    public:
        int* list;
        int size = 0;
        int max;
        // constructor
        MyList(int s)
        {
            max = s;
            size = 0;
            if(max > 0)
                list = new int[max];
        };
        // destructor
        ~MyList()
        {
            for (int x = 0; x < max; x++)
                delete (list + x);
        };
};
I tried to clear the memory with that destructor. However, it throws an error on second iteration. What did I do wrong? Also, it wouldn't let me do it this way:
delete list[x];
Can someone explain to me why? Thank you so much.
 
     
     
    