The new and delete operators are used to dynamically allocate and revoke memory operators
New usage:
1. Open a single variable address space
1) New int; Opens up a storage space for the array and returns an address to the storage space. int *a = new int means assigning an address of type int to integer pointer A.
2 int *a = new int (5) acts as above, but at the same time assigns an integer value of 5
2. Open array Space
One-dimensional: int *a = new INT[100]; Create an integer array space of size 100
Two-dimensional: int **a = new Int[5][6]
Three-dimensional and above: and so forth.
General usage: new type [initial value]
Delete usage:
1. int *a = new int;
Delete A; Free space for a single int
2.int *a = new Int[5];
delete [] A; Frees int array space
To access the structure space opened by new, you cannot go directly through the variable name, only through the assigned pointer.
With new and delete can be dynamically opened, undo the address space. If you run out of a variable (typically a stored array) the next time you need to use it, but you want to omit the reinitialization, you can open up a space each time you start using it, and then undo it when you're done with it.