free(): invalid pointer

new something then delete, but the pointer changed with ++

int main ()
{
        int * ptr;
        ptr = new int [10];
        ptr++;
        delete[] ptr;
        return 0;
}

munmap_chunk(): invalid pointer

#include <iostream>
using namespace std;

class Rectangle
{
        int width, height;
public:
        Rectangle (int x, int y) : width {x}, height {y} {}
        int area(void) {return width * height;}
};

int main()
{
        Rectangle * foo;
        foo = new Rectangle[2] { {2,5}, {3,6} };
        cout << "foo[1]'s area :" << (++foo)->area() << endl;
        delete[] foo;
        return 0;
}

use _CRT_SECURE_NO_WARNINGS

Configuration Properties>>C/C++>>Preporocessor>>Preprocessor Definitions>> _CRT_SECURE_NO_WARNINGS