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 are main features of oop?
What is the renewal class?
What is polymorphism what are the different types of polymorphism?
What is coupling in oops?
Can a destructor be called directly?
Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?
Why is polymorphism used?
What is overriding vs overloading?
Why do pointers exist?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
Can we have inheritance without polymorphism?
What is the real time example of encapsulation?
What type of loop is a for loop?
Is react oop?
Can main method override?