since new and malloc() both are used to allocate memory. the major difference between these two is that malloc does not call the constructor whereas new call the constructor
delete in c++ :-
when memory is allocated using new[] if we use only delete to deallocate it, it deletes the complete array , but if the array is an array of object in the array whereas , on using delete[], it deletes the complete array and calls the destructor for each object in the array;
delete in c++ :-
when memory is allocated using new[] if we use only delete to deallocate it, it deletes the complete array , but if the array is an array of object in the array whereas , on using delete[], it deletes the complete array and calls the destructor for each object in the array;

0 comments:
Post a Comment