User loginNavigationTake FREE online C/C++ test now!Unix / Linux ProgrammingCode search made simpleYour feedback needed!As a webmaster of this site, I regard you as our most important critic and commentator. We value your opinion and want to know what we are doing right, what we could do better and any other words of wisdom you're willing to pass our way. It would be our greatest motivation which will help us in developing areas you would like to see in this site. We hope you will continue to encourage and support us in our future endeavors.
INDIA |
Never mix malloc with delete OR new with freeNever mix malloc with delete OR new with free as the outcome will be undefined behavior. It is not a good programming practice.Let's look at the two undefined behavior due to the mixed usage of malloc with delete OR new with free and learn how to overcome it: * malloc with delete (attached mallocdel.cpp) - In this case, memory is allocated with malloc and it is freed using delete or delete[]. * new with free (attached newfree.cpp) - In this case, memory is allocated using new and it is freed using free. Note: Never mix malloc with delete OR new with free instead always use free with malloc and new with delete or delete[].Few useful external links related to this article:
|