Is there memory area called 'stack' in C++ to store automatic variables

前端 未结 5 472
抹茶落季
抹茶落季 2020-12-16 01:01

Is there a specific area in memory called stack in C++ where automatic variables are getting stored.

5条回答
  •  被撕碎了的回忆
    2020-12-16 01:45

    Please refer to this answer, where I explain this in detail.

    In summary, quoted from it:

    The terms "heap" and "stack" are outdated, relating to back when the most popular runtime libraries used these data structures to store objects which were dynamically- and automatically-allocated, respectively (statically-allocated objects fit into neither category, incidentally).

    These days that is not always true, and it's certainly not mandated by the C++ standard, which does not care where things are stored. It only cares about how they are created and destroyed, and about how long they live.

    Hope that clears things up for you.

提交回复
热议问题