When to use Malloc instead of New [duplicate]
问题 This question already has answers here : Closed 10 years ago . Duplicate of: In what cases do I use malloc vs new? Just re-reading this question: What is the difference between "new" and "malloc" and "calloc" in C++? I checked the answers but nobody answered the question: When would I use malloc instead of new? There are a couple of reasons (I can think of two). Let the best float to the top. 回答1: A couple that spring to mind: When you need code to be portable between C++ and C. When you are