In C++, what does the delete operator do ?

2025

In C++, what does the delete operator do ?

  1. A.

    Deletes a member of a class

  2. B.

    Frees dynamically allocated memory

  3. C.

    Deletes the class definition

  4. D.

    Deallocates an object

Attempted by 62 students.

Show answer & explanation

Correct answer: B

The delete operator in C++ is used to deallocate memory that was previously allocated using the new operator. It calls the destructor for the object and frees the memory back to the heap.

Explore the full course: Tpsc Assistant Technical Officer