What will happen if I allocate memory using "new" and free
it using "free" or allocate sing "calloc" and free it using
"delete"?
Answers were Sorted based on User's Feedback
Answer / sanjay makwana, puna
When you allocate a memory using new then constructor will
be called but when use a free that time destructor will not
be called.
Same vice versa for calloc and delete.
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / ekta
free is not compatible with new.
free wont recognise the memory allocated by new and should
gie some error i guess.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / roshan p.r.
Hi,
you cannot free a memory allocated with new using "free"
and in the same way callac with "delete"
because they are incompatable
| Is This Answer Correct ? | 0 Yes | 6 No |
Is c or c++ more useful?
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].
What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h
What is the default width for ouputting a long integer using the insertion operator?
How to defines the function in c++?
What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?
WHO DEVELOPED C++?
What is #include iostream h in c++?
Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.
What is format for defining a structure?
what is a reference variable in C++?
What does new in c++ do?