Computer Science, asked by bhawani2148, 1 year ago

What is the need to overload new and delete operator?

Answers

Answered by brainlyboytopper
1
The function receives a parameter of type void* and returns nothing. Both functions for new and delete are static by default and can't access this pointer. To delete an array objects, the operator delete[ ] must be overloaded. In the above program, ::new and ::delete refers to the global new and delete operators.
Answered by smartbrainz
0

Overload new and delete operators needed in the memory management of an application.

Explanation:

  • In a C++ application, it happens quite often memory is allocated for usage but never de-allocate explicitly. By overloading new and delete operators we can explicitly do the memory management of an application.
  • Overloading makes use of allocating memory from a memory pool, rather than assigning raw memory from heap each time, i.e. fetch memory from a memory pool and return it after usage.

Similar questions