Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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

What are the advantages of using const reference arguments in a function?

210


What is constructor in C++?

250


What do nonglobal variables default to a) auto b) register c) static

234


What are c++ stream classes?

194


What is c++ hash?

200






Which sort does c++ use?

203


What is the function of I/O library in C++ ?

258


When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

218


How is modularity introduced in C++?

266


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

230


Write is a binary search tree? Write an algo and tell complexity?

240


explain the reference variable in c++?

223


How do you find out if a linked-list has an end? (I.e. The list is not a cycle)

214


What are multiple inheritances (virtual inheritance)? What are its advantages and disadvantages?

201


Write a note about the virtual member function?

221