c++ = delete code example
Example 1: c++ delet from memory
// Delete pointer
int* ptr1 = new int;
delete ptr1;
// Delete array
int* array = new int[10];
delete[] array;
Example 2: c++ erase remove
std::vector<int> v = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
v.erase(std::remove(v.begin(), v.end(), 5), v.end());
// v will be {0 1 2 3 4 6 7 8 9}