This question was asked to me in an interview:
In C++,
- what if we allocate memory using
mallocand usedelete<
1) Undefined behaviour but will probably "work" though. Destructors will get called on the memory being freed that pobably doesn't want to be deconstructed.
2) Undefined behaviour but will probably "work" though. Destructors will NOT get called.
ie IF it works, and there is no guarantee of that, then it will only, likely, work exactly as required for basic builtin data types.