C++ 中的 delete vs delete[] 运算符
What is the difference between delete
and delete[]
operators in C++?
The delete
operator deallocates memory and calls the destructor for a single object created with new
.
The delete []
operator deallocates memory and calls destructors for an array of objects created with new []
.
Using delete
on a pointer returned by new []
or delete []
on a pointer returned by new
results in undefined behavior.
相关文章