Vector

Implement class Vector that provides the vector functionality needed by the test code Vector_test.cpp given below. When you do this, you should not use C++ vector class.

Since Vector is a template container class, it should be implemented in one file: Vector.h. Complete Vector.h given below.

A few points regarding capacity versus size:

  • capacity: amount of memory allocated to the container in terms of number of elements. Number of bytes = capacity * length of T
  • size: number of elements in the container.
  • capacity is always >= size
  • capacity – size = number of elements that can be added without allocating more memory.
  • reserve(): increases capacity by allocating more memory.
  • resize(): could increase or decrease size. When increasing size, if necessary (when size > capacity) increase capacity to match size.
  • In your implementation when size = capacity and push_back() is called, allocate 5 more memory locations first (increase capacity by 5), then insert the new element (increase size by 1).
  • Take a look at capsize.cpp. Compile and run it and make sure you understand what it is doing. 

    Click Order now to have a similar paper completed for you by our team of Experts.

Is this question part of your Assignment?

We can help

Our aim is to help you get A+ grades on your Coursework.

We handle assignments in a multiplicity of subject areas including Admission Essays, General Essays, Case Studies, Coursework, Dissertations, Editing, Research Papers, and Research proposals

Header Button Label: Get Started NowGet Started Header Button Label: View writing samplesView writing samples