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 a singleton c++?
Define private, protected and public access control.
What is null pointer and void pointer?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
What is the average salary of a c++ programmer?
What are the uses of static class data?
Explain the problem with overriding functions
What is array in c++ example?
Who calls main function?
What do you mean by stack unwinding in c++?
Define linked lists with the help of an example.
Is java a c++?
Why is c++ still popular?
What is a friend function in c++?
What is the best c++ ide?