Question: ///////////////////////////////////////////////////// // Instructions: // Part 1: Run the test code using the stl vector class. Make sure you understand the output // and
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\/ // Instructions: \\ // Part 1: Run the test code using the stl vector class. Make sure you understand the output \\ // and how the vector class works. \\ // Part 2: Create your own vector class (in the file "myVector.h"). To test your vector class, \\ // Swap the #include statements above so that the test code uses your vector class instead of the stl vector class. \\ // \\ // YOU MAY NOT CHANGE ANY PART OF THE TEST CODE other than swapping the included files. \\ // Your vector class must yield the exact same results from the test code as the stl vector class, \\ // with the following exceptions: The "capacity" method may return different values \\ // (i.e., you may choose any resizing method you want, but you should consider what is the smartest approach with \\ // respect to efficiency). Additionally, for the 0-parameter constructor and the 1-parameter, you do not need to \\ // initialize the values of the vector items (but you must for the 2-parameter constructor). \\ // Beyond these items, your code must behave the same as for the stl vector. \\ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ #include#include #include //replace this with your own class when ready //#include "myVector.h" //include this instead of the stl vector class when ready using namespace std; int main() { vector myvecA; vector myvecB(10); vector myvecC(5,-9); vector myvecD(6,"Are we there yet?"); //The size method should return how many items, abstractly, //the vector currently holds. cout << "Vector A size: " << myvecA.size() << endl; cout << "Vector B size: " << myvecB.size() << endl; cout << "Vector C size: " << myvecC.size() << endl; cout << "Vector D size: " << myvecD.size() << endl; //Capacity should report how large the array holding the items is. //This size will be at least that of 'size()', but could be larger. cout << "Vector A capacity: " << myvecA.capacity() << endl; cout << "Vector B capacity: " << myvecB.capacity() << endl; cout << "Vector C capacity: " << myvecC.capacity() << endl; cout << "Vector D capacity: " << myvecD.capacity() << endl; //You can access the items in the array //with the '[]' operator. cout << endl; cout << "Vector B: " << endl; myvecB[3] = 43; myvecB[7] = 17; for(int i=0; i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
