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'S THE OOPS BASIC OOPS CONCEPTS IN DOTNET
What is ambiguity in inheritance?
What is protected in oop?
Why we are use # in begning of programme of c++.
What is the purpose of polymorphism?
write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory
design class for linked list and include constructor,destructor,insert option. struct node { int node; struct node &ptr; }
why in java first invoke public static void main(String args[]) method????Why not public static void method1(String args[])??
In multiple inheritance , to create sub class object , is there need to create objects for its superclasses??? in java and c++ both. Actually i have some information that is , all available members from its superclasses , memory created in subclass obj , so no need to create object for its superclasses...??? Thanks in Advance
IN PROGRAMING LANGAUGE A C++ IS PURELY OBJECT ORIENTED OR NOT?
What is the benefit of oop?
Can bst contain duplicates?