what is the return type of new and delete operators?..

Recommended Answers

All 2 Replies

operator new returns a void*, in which it is converted implicitly to whatever
type you are using with assignment operator.

operator delete does not return anything.

As far as I know delete does not return anything whereas new returns a pointer.

For example, when you write-->

new int;

A block of int is allocated in memory and a pointer is returned that points to the beginning of this block in the memory.

So, if you want to assign this pointer, you need to declare a pointer of type int that can hold this pointer.

int *x;
x= new int;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.