Answer Posted / shivi jain
new and delete are C++ specific features. They didn't exist in C. malloc is the old school C way to do things. Most of the time, you won't need to use it in C++.
malloc allocates uninitialized memory. The allocated memory has to be released with free.
calloc is like malloc but initializes the allocated memory with a constant (0). It needs to be freed with free.
new initializes the allocated memory by calling the constructor (if it's an object). Memory allocated with new should be released with delete (which in turn calls the destructor). It does not need you to manually specify the size you need and cast it to the appropriate type. Thus, it's more modern and less prone to errors.
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
What is use of overloading?
What does I oop mean?
How long to learn object oriented programming?
What are the 4 pillars of oop?
What is the difference between inheritance and polymorphism?
Why is abstraction used?
What is a superclass in oop?
assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).
What are the advantages of polymorphism?
Where is pseudocode used?
Give two or more real cenario of virtual function and vertual object
What is super in oop?
What are the 3 principles of oop?
What is coupling in oops?
• What are the desirable attributes for memory managment?