how to remove an elements in an array in C++ code example
Example: delete an array c++
// operator delete[] example
// an advanced example :
#include <iostream>
using namespace std;
struct MyClass {
MyClass() {cout <<"MyClass constructed\n";}
~MyClass() {cout <<"MyClass destroyed\n";}
};
int main () {
MyClass * pt;
pt = new MyClass[3];
delete[] pt;
return 0;
}
//simple exmaple :
int main () {
int * pt;
pt = new int [3];
delete[] pt;
return 0;
}