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
Why the usage of pointers in C++ is not recommended ?
Write about a nested class and mention its use?
How new/delete differs from malloc()/free?
How can you link a c++ program to c functions?
What is meaning of in c++?
What is meant by a delegate?
Why Pointers are not used in C++?
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
Write about the stack unwinding?
Why is swift so fast?
What is a pointer how and when is it used?
What is basic if statement syntax?
Do you know about latest advancements in C++ ?
What are the restrictions apply to constructors and destructors?
What is the importance of mutable keyword?