When and why to declare member variables on the heap C++
问题 Ok, so I'm very new at C++ programming, and I've been looking around for a couple days for a decisive answer for this. WHEN should I declare member variables on the heap vs. the stack? Most of the answers that I've found have dealt with other issues, but I want to know when it is best to use the heap for member variables and why it is better to heap the members instead of stacking them. 回答1: There are two important concepts to grasp first: One should avoid thinking in terms of "heap" and