How to resize array in C++?

前端 未结 6 580
感情败类
感情败类 2020-11-29 09:16

I need to do the equivalent of the following C# code in C++

Array.Resize(ref A, A.Length - 1);

How to achieve this in C++?

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 09:45

    1. Use std::vector or
    2. Write your own method. Allocate chunk of memory using new. with that memory you can expand till the limit of memory chunk.

提交回复
热议问题