Which operator should be used to release a dynamically allocated array in C++?

Options

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

Correct Answer (Detailed Explanation is Below)

C. delete[]

Detailed Explanation

Correct Answer: Option C — delete[]

Explanation: Memory allocated using new[] must be released using delete[]. Example: int *arr = new int[5]; delete[] arr;. Using delete instead of delete[] for an array results in undefined behavior.