the difference between new and malloc

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


Please Help Members By Posting Answers For Below Questions

What is the purpose of polymorphism?

681


write a programe to calculate the simple intrest and compund intrest using by function overlading

1670


Give two or more real cenario of virtual function and vertual object

1851


What is variable example?

595


What are the 4 pillars of oop?

672






What is the oops and benefits of oops programming?

555


What is multilevel inheritance?

727


What does enum stand for?

615


What is polymorphism explain its types?

684


Why do we use class?

635


Which language is not a true object oriented programming language?

642


how to get the oracle certification? send me the answer

1670


What are the important components of cohesion?

557


What exactly is polymorphism?

610


Can you name some types of inheritance?

641