Interviewer And Interviewee Guide

C++ New And Delete Interview Question:

Can you please explain the difference between new and malloc and delete and free()

Submitted by: Administrator
Delete is assocated with new and free(0 is associated with malloc()

New
Its an operator
delete is associated with new
It creates an object
It throws exceptions if memory is unavailable
Operator new can be overloaded
You can state the number of objects to be created.

malloc()
It's a function
free() is associated with malloc()
It does not create objects
It returns NULL
This cannot be overloaded
You need to specify the number of bytes to be allocated.
Submitted by: Administrator

Read Online C++ New And Delete Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.