I came across an issue which I could not resolve.
My question is, if I used malloc
to allocate memory and then memory block is delete using delete
Many good reasons have already been given. I'll add one more reason: the new
operator can be overriden in c++. This allows the user to specify their own memory management model if they so desire. Although this is pretty uncommon, its existence is just one more reason why malloc and new, delete and free cannot be used interchangeably. This is for the reason described by @Patz.