Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
they are basically the same. new is a feature of c++ and malloc of c. malloc only allocates uninitialized memory, new allocates memory and calls constructor. malloc return void* and needs to be type casted to a specific type,new returns type casted pointer. This is not a diference: it may be possible that implementation of new operator might have malloc function present in it.
5th Nov 2016, 2:54 AM
kamal joshi
kamal joshi - avatar