New and delete can effectively and directly allocate and release dynamic memory. The new operator returns a pointer of the specified type. If the allocation fails (if there is not enough memory space), 0 is returned. For example, double * p; p = new double; * p = 30.4; // store the value in the opened unit. The system automatically opens up the memory unit according to the space size of the double type, and put the address in Pointer p. Of course, you can also initialize the value in the unit when opening up the memory unit. The preceding code is equivalent to: double * p; p = new double (30.4); the delete operator releases the memory of the new request channel. Delete p releases the memory unit of the p pointer. the pointer Variable p is still valid and can be directed to another memory unit. New can also allocate memory to the array. When released, it can also tell the number of delete arrays. For example: int * p; p = new int [10]; delete [10] p; // tell the delete array how many elements are there, or delete [] p;