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 pointers in a program?

668


What is the latest c++ version?

600


What are the different types of comments allowed in c++?

566


What is abstract class in c++?

579


what are the iterator and generic algorithms.

1451






What is the basic of c++?

590


What is struct c++?

560


Will a recursive function without an end condition every quit, in practice a) Compiler-Specific (Some can convert to an infinite loop) b) No c) Yes

574


What are stacks? Give an example where they are useful.

584


What is the difference between ++ count and count ++?

569


What happens when the extern "c" char func (char*,waste) executes?

625


What is the best c++ ide?

592


Incase of a function declaration, what is extern means?

508


Where is atoi defined?

571


What is function overloading c++?

562