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 |
How do you achieve polymorphism?
Difference between realloc() and free?
What is oops in simple words?
write knight tour problem which is present in datastructure
What is static modifier?
What does sksksk mean in text slang?
what are abstract classes and how they impliment , with example
Which is not an object oriented programming language?
How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction
program in c++ that can either 2 integers or 2 floating point numbers and output the smallest number
what is the difference between inter class and abstract class...?
What do you mean by binding of data and functions?