how to remove an element from an array c++ code example
Example 1: how to delete an element from an array
var array = [123, "yee", true];
array.pop(index);
Example 2: how to delete something in an array c++
delete myarray[elemen];
Example 3: delete an array c++
#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;
}
int main () {
int * pt;
pt = new int [3];
delete[] pt;
return 0;
}