Difference between global non-throwing ::operator new and std::malloc

前端 未结 3 1573
一生所求
一生所求 2020-12-05 03:00

C++ has several functions to acquire dynamic storage, most of which differ in some fundamental way. Several more are usually added by the OS.

Two of these are of spe

3条回答
  •  攒了一身酷
    2020-12-05 03:31

    There are two differences I can think of:

    1. Which function you must use to deallocate the memory, operator delete vs. free().

    2. A C++ program can legally provide its own version of ::operator new and that version is guaranteed to be called by new expressions. It's not possible to override malloc with your own version.

提交回复
热议问题