Static array vs. dynamic array in C++

Local arrays are created on the stack, and have automatic storage duration — you don’t need to manually manage memory, but they get destroyed when the function they’re in ends. They necessarily have a fixed size:

int foo[10];

Arrays created with operator new[] have dynamic storage duration and are stored on the heap (technically the “free store”). They can have any size, but you need to allocate and free them yourself since they’re not part of the stack frame:

int* foo = new int[10];
delete[] foo

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)