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


Please Help Members By Posting Answers For Below Questions

Is python better than c++?

666


How much do coding jobs pay?

645


What is a linked list in c++?

653


I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?

1665


What does it mean to declare a destructor as static?

714






What is a class template in c++?

630


What is ofstream c++?

697


Why is c++ so fast?

624


How delete [] is different from delete?

682


Comment on local and global scope of a variable.

671


What are pointer-to-members? Explain.

718


What is std namespace in c++?

807


What is increment operator in c++?

646


When we use Abstract Class and when we use Interface?where we will implement in real time?

1766


Is c++ free?

704