Shall we use 'free' to free memory assigned by new, What are
the further consequences??
Answer Posted / krishnarao panchadi
Syntactically we can use "free" in place of "delete". But
semantically it is senseless as it wont call the destructor.
Note that, deallocating is not the only purpose of
using "delete". The destructor should also be called if you
call the constructor(while creating the object).
Failing to call "delete" may lead to system crash.
Using "free" wont call the desturctor.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is data type in c++?
Name the debugging methods that are used to solve problems?
Is turbo c++ free?
What is the disadvantage of using a macro?
What is an operator 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.
Is python written in c or c++?
What is a map in c++?
What does h mean in maths?
What is a static element?
Explain all the C++ concepts using examples.
What are dynamic type checking?
What is c++ flowchart?
Write about the retrieval of n number of objects during the process of delete[]p?
What are the advantages of using a pointer? Define the operators that can be used with a pointer.