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 is virtual constructors/destructors?
What is the difference between the c++ & java?
What is polymorphism and example?
1. Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)
What are the OOPS concepts?
106 Answers A1 Technology, Bajaj, CTS, EDS, HP, Infosys, Intel, Microsoft, MNC, Persistent, PlanetSoft, ProConstructor, TCS, Virtusa, Wipro, YSoft Solutions,
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
What does no cap mean?
what is use to destroy an object? illustrate.
explain dynamic binding by drowing
what is graphics
what is the difference between containership and inheritence?
A file pointer always contains the __________ of the file