Do something to improve things. Anything. Start small or go big. Just do something. Today. Now. The world will be better for it. ----Just because no one else believes in your dreams doesn't mean you shouldn't believe in your dreams. ----The world is the great gymnasium where we come to make ourselves strong. "Swami Vivekananda"

Government Jobs In India Headline Animator

22 July 2011

What is difference between new and malloc?


Besides the basic syntactical difference:

malloc is a C function which will allocate the amount of memory you 
ask and that's it.

new  is a C++ operator which will allocate memory AND call
the constructor of the class for which's object memory is
being allocated.Similarly, free is a C function which will free 
up the memory allocated.


but delete is a C++ operator which will free up the allocated 
memory AND call the destructor of the object.

No comments:

Subscribe via email

Enter your email address:

Delivered by FeedBurner

website-hit-counters.com
Provided by website-hit-counters.com site.