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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is size_type?

541


What is lambda expression c++?

571


What do you mean by funtion prototype?

578


Differentiate between realloc() and free().

588


When does a name clash occur in c++?

707






What is #include iomanip?

536


an operation between an integer and real always yeilds a) integer result b) real result c) float result

701


What do you mean by const correctness?

620


Do inline functions improve performance?

638


Why are pointers not used in c++?

621


What is the main use of c++?

545


Is recursion allowed in inline functions?

603


Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);

612


What is the maximum value of a unsigned char a) 255 b) 256 c) 128

625


If you want to share several functions or variables in several files maitaining the consistency how would you share it?

548