What is the difference between creating an object,
using 'new' and using 'malloc'?

Answer Posted / btech

new operator returns a pointer of the correct type and
malloc() returns a void*

New calls the object’s constructor and malloc does not.

Any object created with new must be freed using delete and
where as malloc() and free() allocates and deallocates
memory

new operator can be overloaded by a class, where as
malloc() can't be overloaded.

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?

3694


What is abstraction in c++ with example?

558


What are the rules about using an underscore in a c++ identifier?

629


What is abstraction example?

614


What is a local reference?

669






What are abstract data types in c++?

526


Explain explicit container.

631


Write a program to find the Fibonacci series recursively.

601


What do you mean by early binding?

597


Is it possible for a member function to delete the pointer, named this?

608


What is inheritance write a program to show use of inheritance?

611


Why is c++ called oops?

550


Describe new operator?

614


What are structs in c++?

596


Is c++ built on c?

556