How to resize array in C++?

前端 未结 6 566
感情败类
感情败类 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:48

    Raw arrays aren't resizable in C++.

    You should be using something like a Vector class which does allow resizing..

    std::vector allows you to resize it as well as allowing dynamic resizing when you add elements (often making the manual resizing unnecessary for adding).

提交回复
热议问题