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 |
write a c++ code to overload + and - for a stack class such that + provides push and - provides pop operation
1 Answers College School Exams Tests, HCL, IBM, TCS,
What type of Job you are providing?
Please send ford technologies placement paper 2 my mail id
When you define a integer it gets stored in which data structure?(Stack or a heap)
What is balance factor?
why function overloading is not called as pure polymorphism?
Why do we use virtual functions?
What is the difference between inheritance and polymorphism?
what is polymorpsim? what are its types?
can we make game by using c
Why static functions always uses static variables?
What is polymorphism in oop example?