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/
Nhận xét
Đăng nhận xét