In C++, what does the delete operator do ?
2025
In C++, what does the delete operator do ?
- A.
Deletes a member of a class
- B.
Frees dynamically allocated memory
- C.
Deletes the class definition
- 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.