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 |
why destructor is not over loaded?
Generally, in all C++ programs, texts are in white colour. Can we change the colour of the text(either input or output or both)? If so, help me out.
Difference between new operator and operator new
Can you explain polymorphism?
What is difference between multiple inheritance and multilevel inheritance?
write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.
Why is oop useful?
How do you explain polymorphism?
how to find the largest of given numbers in an array
What are constructors in oop?
Why static Function is used in C++?
In which cases you use override and new base?