What will happen if I allocate memory using "new" and free
it using "free" or allocate sing "calloc" and free it using
"delete"?

Answers were Sorted based on User's Feedback



What will happen if I allocate memory using "new" and free it using "free" or a..

Answer / sanjay makwana, puna

When you allocate a memory using new then constructor will
be called but when use a free that time destructor will not
be called.

Same vice versa for calloc and delete.

Is This Answer Correct ?    6 Yes 0 No

What will happen if I allocate memory using "new" and free it using "free" or a..

Answer / ekta

free is not compatible with new.
free wont recognise the memory allocated by new and should
gie some error i guess.

Is This Answer Correct ?    0 Yes 1 No

What will happen if I allocate memory using "new" and free it using "free" or a..

Answer / roshan p.r.

Hi,

you cannot free a memory allocated with new using "free"
and in the same way callac with "delete"

because they are incompatable

Is This Answer Correct ?    0 Yes 6 No

Post New Answer

More C++ General Interview Questions

Explain how to initialize a const member data.

0 Answers  


Why do we need function?

0 Answers  


What is the difference between object-oriented programming and procedural programming?

0 Answers  


What is function overloading c++?

0 Answers  


What character terminates all character array strings a) b) . c) END

0 Answers  






What do you mean by function pointer?

0 Answers  


How can you force instantiation of a template?

1 Answers   ABC, Amazon,


Do you know the use of vtable?

0 Answers  


What is the difference between set and map in c++?

0 Answers  


Define stacks. Provide an example where they are useful.

0 Answers  


What is singleton class in c++?

0 Answers  


What is array in c++ pdf?

0 Answers  


Categories