In what cases do I use malloc and/or new?

前端 未结 19 1676
北恋
北恋 2020-11-21 17:41

I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the

19条回答
  •  青春惊慌失措
    2020-11-21 18:00

    If you have C code you want to port over to C++, you might leave any malloc() calls in it. For any new C++ code, I'd recommend using new instead.

提交回复
热议问题