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 do you mean by abstraction?
IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?
Whats oop mean?
i got a backdoor offer in process global,Bangalore..Can i work with it?
Why is abstraction needed?
What is constructor overloading in oop?
What is oops in simple words?
What is class and object with example?
Why we use classes in oop?
write a program that takes input in digits and display the result in words from 1 to 1000
What is pure oop?
What is polymorphism in oops with example?
given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy
Get me an image implementation program.
Prepare me a program for the animation of train