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
Is there a sort function in c++?
How are the features of c++ different from c?
How do I run a program in notepad ++?
True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends
What is the difference between global int and static int declaration?
What is runtime polymorphism in c++?
What are the advantage of using register variables?
What is purpose of abstract class?
What is buffering in c++?
What is the two main roles of operating system?
What is the exit function in c++?
Is c++ pass by reference or value?
What is the size of a vector?
What new()is different from malloc()?
what is COPY CONSTRUCTOR and what is it used for?