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

前端 未结 15 2708
春和景丽
春和景丽 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:02

    The most relevant difference is that the new operator allocates memory then calls the constructor, and delete calls the destructor then deallocates the memory.

提交回复
热议问题