Which operator should be used to release memory allocated using new[] for a C++ array?

Options

  • A. delete
  • B. delete[]
  • C. free[]
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. delete[]

Detailed Explanation

Answer: (B) delete[]

Memory allocated using new[] should be released using delete[].

Example:

int *p = new int[10];
delete[] p;

The square brackets in delete[] indicate that the allocated object is an array.

Using the correct deallocation form is important for proper memory management in C++.