List and list elements, where are stored?

前端 未结 7 1606
粉色の甜心
粉色の甜心 2021-01-05 17:59

Given this piece of code:

#include 
(void) someFunction(void) {
    list  l;
    l.push_back(1);
}
  • Where are t
相关标签:
7条回答
  • 2021-01-05 19:02

    Where are the elements of the list stored? Stack? Heap?

    The elements held by the list are typically dynamically allocated so this will be on the heap.

    This function can returns the list?

    No it cannot, you declared your function with a return type of void.

    How can I do to empirically check that values are in stack or heap?

    The only way to be really sure is to peek into the std::list implementation to see what it's really doing. But you don't really need to care about this since it's an implementation detail.

    0 讨论(0)
提交回复
热议问题