malloc() is a C library function that can also be used in C++, whereas the “new” operator is only available in C++.
Both malloc() and new are used to dynamically allocate memory in heap.
However, “new” invokes the constructor of a class, whereas “malloc()” does not.
Vishalini.R Answered question June 28, 2023
