Why use new and delete at all?
问题 I'm new to C++ and I'm wondering why I should even bother using new and delete? It can cause problems (memory leaks) and I don't get why I shouldn't just initialize a variable without the new operator. Can someone explain it to me? It's hard to google that specific question. 回答1: For historical and efficiency reasons, C++ (and C) memory management is explicit and manual. Sometimes, you might allocate on the call stack (e.g. by using VLAs or alloca(3)). However, that is not always possible,