why the memory allocated with new cant be freed using free()

Answer Posted / durgalakshmi

new keyword does two things.
1) allocate memory using new operator
2) invokes the constructor.

so the allocated memory using new should be freed only by
delete which frees the memory by calling the destructor.

But free will not do these things.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the features of oop?

624


What is this pointer in oop?

543


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

685


What is class and object with example?

578


Please send ford technologies placement paper 2 my mail id

1646






i got a backdoor offer in process global,Bangalore..Can i work with it?

2314


If a=5, b=6, c=7, b+=a%c*2. What is the final value of b?

933


What is the difference between inheritance and polymorphism?

579


what is the drawback of classical methods in oops?

2907


what type of question are asked in thoughtworks pair programming round ?

1749


write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

2748


What is encapsulation process?

571


How is class defined?

571


What are constructors in oop?

581


What are the three parts of a simple empty class?

1445