delete vs delete[] operators in C++

后端 未结 6 1138
[愿得一人]
[愿得一人] 2020-11-22 06:13

What is the difference between delete and delete[] operators in C++?

6条回答
  •  北海茫月
    2020-11-22 06:52

    The operators delete and delete [] are used respectively to destroy the objects created with new and new[], returning to the allocated memory left available to the compiler's memory manager.

    Objects created with new must necessarily be destroyed with delete, and that the arrays created with new[] should be deleted with delete[].

提交回复
热议问题