why the memory allocated with new cant be freed using free()
Answers were Sorted based on User's Feedback
new keyword does two things.
1) allocate memory using new operator
2) invokes the constructor.
so the allocated memory using new should be freed only by
delete which frees the memory by calling the destructor.
But free will not do these things.
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / bharti
Because with new operator in C++ delete operator is used to
deallocate the memory. And with malloc() free() is used. S
it may not be supported by some of the compilers to free
memory with free() created by new.
| Is This Answer Correct ? | 1 Yes | 1 No |
What are the two different types of polymorphism?
What is abstraction encapsulation?
what is difference between c++ language and java language
Write pseudo code for push in a stack?
What is constructor overloading in oop?
What is the different between Applet and Application?
why reinterpret cast is considered dangerous?
What is Method overloading?
what is data hiding.
which is platform independent device used in computers
What does oop mean in snapchat?
What is polymorphism what is it for and how is it used?