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 |
Who discovered c++?
What are the sizes and ranges of the basic c++ data types?
How many keywords are used in c++?
True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends
Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == 4 ) y-= 7; else y = 8; Enter a segment of code (without any IF statements) that does exectly the same thing using the switch structure.
when can we use virtual destructor?
7 Answers HCL, HP, Virage Logic,
Does c++ have a hash table?
Explain RAII (Resource Acquisition Is Initialization).
What is the difference between #define debug 0 and #undef debug?
What is RAII (Resource Acquisition Is Initialization)?
Explain working of printf?
What is problem with Runtime type identification?