What is the difference between new/delete and malloc/free?

前端 未结 15 2927
春和景丽
春和景丽 2020-11-21 23:53

What is the difference between new/delete and malloc/free?

Related (duplicate?): In what cases do I use malloc vs

15条回答
  •  春和景丽
    2020-11-22 00:03

    • To use the malloc(), we need to include or in the program which is not required for new.
    • new and delete can be overloaded but malloc can not.
    • Using the placement new, we can pass the address where we want to allocate memory but this is not possible in case of malloc.

提交回复
热议问题