C++ forbids variable-size array

后端 未结 3 1911
面向向阳花
面向向阳花 2021-01-17 08:18

I am using some existing code that someone else has written, and I cannot get it to compile (limited C experience here but I am trying to learn!).

utilities.

3条回答
  •  深忆病人
    2021-01-17 09:09

    They are forbidden, but a workaround is to use a stack allocator, for example:

    http://howardhinnant.github.io/stack_alloc.html

    You can use the stack allocator with a ::std::vector (or with some other container, or just directly) and you've got yourself a VLA.

提交回复
热议问题