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

Is java the same as c++?

0 Answers  


If you had the following code: int x = 23; int *y; y = &x; The instruction y++; does what?

2 Answers  


What does h mean in maths?

0 Answers  


What is istream c++?

0 Answers  


Why the usage of pointers in C++ is not recommended ?

0 Answers   TCS,






What is c++ programming language?

0 Answers  


How does a copy constructor differs from an overloaded assignment operator?

0 Answers  


what is the size of a class which contains no member variables but has two objects??? is it 1 or 2??

4 Answers  


What are advantages of C++ when comparing with C?

18 Answers   HP, iGate, TCS,


How to avoid a class from instantiation?

8 Answers   Symphony,


What is a storage class?

0 Answers  


What are the storage qualifiers?

0 Answers  


Categories