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 java the same as c++?
You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()
What is the difference between global variables and local variable
Discussion on error handling of C++ .
What's the hardest coding language?
Explain "const" reference arguments in function?
Should you pass exceptions by value or by reference?
What is the use of 'using' declaration 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?
Is c++ vector dynamic?
Should I learn c++ c?
Explain differences between new() and delete()?
What are the two types of comments?
How many namespaces are there in c++?
What is the first name of c++?