Question: C++ write void resize(unsigned size, int value = 0) This function resizes the vector to contain size elements. If size is smaller than the current
C++
write void resize(unsigned size, int value = 0)
This function resizes the vector to contain size elements. If size is smaller than the current size(_size), this function just reduces the value of _size to size. If size is greater than the current size(_size), then the appropriate number of elements are inserted at the end of the vector, giving all of the new elements the value passed in through the 2nd parameter (value). If the new value of size will be larger than capacity, then the capacity must first be expanded by either doubling (expand()) or by increasing the capacity by a specific amount (expand(new size - current capacity)), whichever results in the largest capacity. Then, this function can increase the size appropriately.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
