Chủ Nhật, 1 tháng 10, 2017

[C] Difference between new and malloc

new malloc
calls constructor doesnot calls constructors
It is an operator It is a function
Returns exact data type Returns void *
on failure, Throws On failure, returns NULL
Memory allocated from free store Memory allocated from heap
can be overridden cannot be overridden
size is calculated by compiler size is calculated manually

Nguồn: http://www.geeksforgeeks.org/malloc-vs-new/

Không có nhận xét nào:

Đăng nhận xét