The new operator is almost the same as a malloc call, except that it invokes a constructor call on the object created immediately after the memory is allocated. Objects allocated with the new operator should be de-allocated with the delete operator (and not free()).
Unmanaged memory – using new/delete
Getting ready
In C++, use of malloc() was replaced as a best practice by use of the new operator. The main difference between the functionality of malloc() and the new operator is that new will call the constructor on object types after memory allocation. Refer to the following table:
malloc |
Allocates a zone of contiguous space for use |
new |
Allocates a zone of contiguous space for use Calls constructor as an... |