# What is the use of new and delete operators? Illustrate with example. What are advantages of new malloc.

The new operator denotes a request for memory allocation on the Free Store. If sufficient memory is available, new operator initializes the memory and returns the address of the newly allocated and initialized memory to the pointer variable.

Synatx:

pointer-variable = new data-type;

Once we no longer need to use a variable that we have declared dynamically, we can deallocate the memory occupied by the variable.

For this, the delete operator is used. It returns the memory to the operating system. This is known as memory deallocation.

Synatx:

delete pointer-variable;

Advantage of new over malloc are

• new does not need the sizeof() operator where as malloc() needs to know the size before memory allocation.
• Operator new can make a call to a constructor where as malloc() cannot.