Would it be considered bad style to use both the new and malloc statements in the same C++ file? It's a small file, less than 120 lines of code. No classes are used and there are only two #include headers, <iostream> and <fstream>.
Would it be considered bad style to use both the new and malloc statements in the same C++ file? It's a small file, less than 120 lines of code. No classes are used and there are only two #include headers, <iostream> and <fstream>.
Last edited by thetinman; 03-31-2007 at 07:16 AM. Reason: details
It's cool if you don't mix new/delete and malloc/free, but you'll get confused about what pointer was created with new and what pointer was created with malloc. That makes working on your code harder, regardless of how short it is.
Unless it's some ancient C++ which is being maintained, you should be using new/delete in all your C++ code.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.