What is the difference between Static and Dynamic arrays in C++?

Static 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 at compile time: int foo[10]; Arrays created with operator new[] have dynamic storage duration and are stored on the heap … Read more

Difference between static memory allocation and dynamic memory allocation

This is a standard interview question: Dynamic memory allocation Is memory allocated at runtime using calloc(), malloc() and friends. It is sometimes also referred to as ‘heap’ memory, although it has nothing to do with the heap data-structure ref. int * a = malloc(sizeof(int)); Heap memory is persistent until free() is called. In other words, … Read more