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 is runtime errors c++?

564


Describe the setting up of my member functions to avoid overriding by the derived class?

602


What is a storage class used in c++?

606


What jobs can you get with a c++ certification?

575


What is a multimap c++?

667






What are c++ storage classes?

614


What is the benefit of learning c++?

545


Name the debugging methods that are used to solve problems?

574


Describe the syntax of single inheritance in C++?

639


What is a multiset c++?

545


What is null pointer and void pointer and what is their use?

581


What is difference between array and vector in c++?

554


How many types of classes are there in c++?

589


What are vectors used for in c++?

615


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

600