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 |
Can we create object of interface?
swapping program does not use third variable
I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...
what is the definition of incapsulation
what is the need of abstraction? what is abstraction?what is the abstraction for stack?
What is static modifier?
What does I oop mean?
Who invented oop?
What is the diamond problem in inheritance?
what is SPL in c++.
What is abstraction?
what is the use of classes in c++;