Technical Discussion :: C++
Home > Technical Interview Q&A > C++ > Discussion
81 / 187
Explain overloading the delete operator.
Answer:
Syntax:
void operator delete(void *p)
{
/*free memory pointed to by p. the destructor is called automatically.*/
}
The delete function receives a pointer to the region of memory to be freed. It then releases the previously allocated memory back to the system. When an object is deleted, its destructor is automatically called.
Asked In ::
Anjani
23 Feb, 2019 5:07 AM
Syntax:
void operator delete(void *p)
{
/*free memory pointed to by p. the destructor is called automatically.*/
}
The delete function receives a pointer to the region of memory to be freed. It then releases the previously allocated memory back to the system. When an object is deleted, its destructor is automatically called.
void operator delete(void *p)
{
/*free memory pointed to by p. the destructor is called automatically.*/
}
The delete function receives a pointer to the region of memory to be freed. It then releases the previously allocated memory back to the system. When an object is deleted, its destructor is automatically called.