简体   繁体   中英

C++ dynamic array constructor

I have been asked to implement a dynamic array in C++. For the constructor we are to "allocate default buffer or wait for first insert".

I do not understand what a default buffer is and why it would it speed up memory operations. Also, what does it mean when it says wait for the first insert?

  1. a default buffer, would mean a default size that the array has from start when you create the instance of your dynamic array, then when the array increases you do not need to increase the buffer until that space has run out.

  2. having no default buffer but once the user inserts the first element into the array, then you allocate memory for one element (or multiple elements in a buffer).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM