malloc() returns a void pointer it is necessary to explicitly typecast it into an appropriate type of pointer.
This gets completely avoided when using new operator. E.g
int *ptr1 = (int *)malloc(sizeof(int));
float *ptr2 = (float *)malloc(sizeof(float));
ExampleClass *ptr3 = (ExampleClass*)malloc(sizeof(sample));
Here ExampleClass is a user defined class.
int *ptr1 = new int;
int *ptr2 = new int;
ExampleClass *ptr3 = new ExampleClass;
new automatically calls the constructor while malloc does not.
new returns a fully typed pointer while malloc returns a void*.
new being an operator can be overloaded while malloc cannot