Thủy Lực Trần Thủy Lực Trần - 1 year ago 113
C++ Question

C++ local container

In C++ when I use array with determined size like:

int a[10000];
in a function as a local variable, the allowed size is smaller than if I declare it as global variable.

I know this is due to the stack size of function.

But what about containers like vector, list, queue, stack, priority_queue, map, etc. ? Are they limited when being local variables like
int a[10000]

Answer Source

std::array has the same space constraints as C-style arrays do. All other standard containers allocate their memory dynamically, and are thus not limited by stack size.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download