Besides the basic syntactical difference:
malloc is a C function which will allocate the amount of memory you
ask and that's it.
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.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
No comments:
Post a Comment