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
What is c++ flowchart?
Define virtual constructor.
Why is polymorphism useful?
How to declaring variables in c++?
What is function overloading c++?
Why should you learn c++?
What are the advantages of using a pointer?
Explain abstraction.
Differentiate between an inspector and a mutator ?
How would you use the functions sin(), pow(), sqrt()?
What is a modifier in c++?
What do c++ programmers do?
I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.
What are maps in c++?
Do inline functions improve performance?