1. Create a new dynamic variable of the specified type with the operator new, and return a pointer to the new variable.
int *p;
p=new int;
The C + + standard stipulates that if there is not enough memory to create a new variable, operator new will terminate the program by default.
The system retains a special memory area for the dynamic variable, which is called free storage. Any new dynamic variable created by the program consumes part of the memory in free storage. If your program creates too many dynamic variables, you may run out of all memory in free storage.
The operator Ndelete destroys a dynamic variable and returns the memory it occupies to free storage. This allows you to reuse those memory to create a new dynamic variable. For example, a statement can destroy a dynamic variable that the pointer variable p points to:
Variables created using the new operator are called dynamic variables because they are created and destroyed when the program is run. Compared to these dynamic variables, the normal variable seems to be static, but that's not the case. Think about the formal parameters of a function.
Delete p;
2. Virtual Suspension pointer
If a pointer variable points to a destroyed dynamic variable, that pointer also enters an undefined state. These undefined pointer variables are called virtual overhang pointers.