Gone3
Gone3

Reputation: 1

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?

Upvotes: 0

Views: 72

Answers (1)

AndersK
AndersK

Reputation: 36082

  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).

Upvotes: 3

Related Questions