Answer Posted / sanish joseph
both malloc and new functions are used for dynamic memory
allocations and the basic difference is: malloc requires a
special "typecasting" when it allocates memory for eg. if
the pointer used is the char pointer then after the
processor allocates memory then this allocated memory needs
to be typecasted to char pointer i.e (char*).but new does
not requires any typecasting. Also, free is the keyword used
to free the memory while using malloc and delete the keyword
to free memory while using new, otherwise this will lead the
memory leak.
Is This Answer Correct ? | 13 Yes | 8 No |
Post New Answer View All Answers
What is the fundamental idea of oop?
What is constructor overloading in oop?
write knight tour problem which is present in datastructure
Why do we use inheritance?
Why do we need polymorphism in c#?
#include
What are two types of polymorphism?
to find out the minimum of two integer number of two different classes using friend function
Why do we use encapsulation in oops?
Why oops is important?
Prepare me a program for the animation of train
Get me a number puzzle game-program
write string class as your own class in java without using any built-in function
What are the three main types of variables?
What is encapsulation example?