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
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 |
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 |
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 |
What are the advantages and disadvantages of using inline and const?
2 Answers Polaris, TCS, Zimmer Biomet,
Definition of class?
What is multithreading and what is its use?Whats are multithreading techniques used in C++?
Define what is constructor?
How many ways are there to initialize an int with a constant?
Explain the static storage classes in c++.
Should I learn c or c++ first?
Why is c++ so fast?
What will happen if when say delete this ?
Can a program run without main in c++?
What is oops in c++?
There is a array of 99 cells and we have to enter 1-100 elements in it , no two elements would repeat , so the is one no. missing because 99 cells and 1-100 nos. so we had to implement a function to find that missing no.