Explain the difference between new/delete and malloc/free.

Last updated 21 June 2026

  • new/delete are type-aware operators that run constructors and destructors. malloc/free only manage raw bytes and return untyped void*.

  • On failure new throws std::bad_alloc while malloc returns nullptr. Only new can be overloaded.

  • Mixing them (e.g. free on a newed pointer) is undefined behavior. Prefer smart pointers in modern C++.

  • https://dev.to/suraj_kumar_fb57ae0928df2/c-interview-questions-a-complete-guide-for-job-seekers-clp
All C++ interview questions