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
Can malloc be used in c++?
Is c++ pass by reference or value?
What is the full form of dos?
Why do we use using namespace std in c++?
Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
What does asterisk mean in c++?
Can we sort map in c++?
Explain the advantages of using friend classes.
What is c++ manipulator?
Can we define function inside main in c++?
Tell me can a pure virtual function have an implementation?
How can I learn dev c++ programming?
Describe new operator?
What is an orthogonal base class in c++?
Can non graphic characters be used and processed in C++?