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??

Answers were Sorted based on User's Feedback



Shall we use 'free' to free memory assigned by new, What are the further consequences??..

Answer / aruna kumar samal

yes you can use free to free memory assignrd by new but it
wo not call the destructor.

Is This Answer Correct ?    6 Yes 0 No

Shall we use 'free' to free memory assigned by new, What are the further consequences??..

Answer / uma sankar pradhan

No,we shouldnot use 'free' to free memory assigned by new.
It causes memory leak and sometimes hanging of the system

Is This Answer Correct ?    3 Yes 0 No

Shall we use 'free' to free memory assigned by new, What are the further consequences??..

Answer / nishikant sahu

Yes you can but not recommend, b'c some time when you class
hold the heap memory it can't be free by "Free" b'c of no
constructor call happening via "Free" and you get the memory
leak. so use New/ delete or malloc/free pair.

Is This Answer Correct ?    3 Yes 1 No

Shall we use 'free' to free memory assigned by new, What are the further consequences??..

Answer / guest

Yes we can use free which was assigned by new.but in this
case no destrctor will be called as free doesn't call this.
So it is recommended that we should not use free if we
allcoate the memory using new.

Is This Answer Correct ?    2 Yes 0 No

Shall we use 'free' to free memory assigned by new, What are the further consequences??..

Answer / 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



More C++ General Interview Questions

What is the array and initializing arrays in c++?

0 Answers  


What is a 'pure' virtual function and what's its use?

1 Answers  


Does there exist any other function which can be used to convert an integer or a float to a string?

0 Answers  


1.what is the difference between software & package &application.

1 Answers   Infosys,


How do we balance an AVL Tree in C++?

0 Answers   Impetus,






What is a .h file c++?

0 Answers  


How can you differentiate between inheritance and implementation in c++?

0 Answers  


Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.

0 Answers   CIIT Wah,


Comment on c++ standard exceptions?

0 Answers  


How do pointers work?

0 Answers  


What is a linked list in c++?

0 Answers  


Write a program to find the Factorial of a number

0 Answers  






Categories