is this dynamic array

Hey guys
is this dynamic array ?
recently I remembered looking into this website's tutorial a year ago
and this is written in the dynamic array section
1
2
3
int size;
std::cin >> size;
int arr[size]
No, this is a variable length array.

The problem is that it might or might not exhaust the stack memory.
In addition, that is not standard C++, although some compilers allow that by non-standard extension.
so...that means this website's tutorial is wrong...
How so?
I remember reading about this somewhere in this website
pardon me, I think my memories are incorrect
www.cplusplus.com/doc/tutorial/dynamic
"Dynamic" typically means that you have manually allocated data from the global store (or "heap"). [small](There are other meanings to "dynamic" too. Just like "window".)[/code]

The differences between a dynamic array and a VLA are:
  1. Who is doing the allocating
  2. Where the memory comes from
  3. What additional information comes with the allocation

From new/malloc()/etc:
  1. You do the allocating/cleanup
  2. The memory comes from the global heap
  3. No additional information about the array

A VLA is different:
  1. The compiler does the allocating/cleanup
  2. The memory comes from the local store (stack space)
  3. Array size/type/indexing information is included

The idea with a VLA is to be able to dynamically allocate a local array. The problem is that it isn't really a normal local array, and the compiler must jump through some interesting hoops to make it work. Some of those hoops don't work quite right.

For now, it is non-standard and somewhat glitchy, so avoid VLAs.
Note that std::vector could be considered a dynamic array.

http://www.cplusplus.com/reference/vector/vector/
https://en.wikipedia.org/wiki/Dynamic_array
It is dynamic in two different ways:

1. It uses dynamic memory (from the heap)
2. It can change its size
Topic archived. No new replies allowed.