Question: need help on c++ programming please 1. The function fill_vector assumes that its argument is a vector that already has allocated some space which needs

need help on c++ programming please

need help on c++ programming please 1. The function fill_vector assumes that

its argument is a vector that already has allocated some space which

needs to be filled. We can do this by using the push

back method provided by the vector class. Look up the push_back routine

in the .NFT help database and ask your TA for help if

you want more clarification Now in your hcader file implement the void

1. The function fill_vector assumes that its argument is a vector that already has allocated some space which needs to be filled. We can do this by using the push back method provided by the vector class. Look up the push_back routine in the .NFT help database and ask your TA for help if you want more clarification Now in your hcader file implement the void add_numbers (vector &data) method that adds 10 random numbers to the data vector (fcel frec to usc a for loop). Test your code by creating an empty vector in main(), call the add_number function, and then print the vector from main(). Another interesting test you should try is calling add_number twice in a row with the same argument - what happens? [L4.P1] 2 Take a look at the sample print function provided in the VectorDriver, and then create a new function void print_even(const vector& data) that prints all of the elements in the data vector that are stored at an even index (i.e data.at(0), data.at(2), ...) Never hesitate to ask the TA for help if you run into problems! [L4.P2] In the tasks above, we used the at () method to access elements of a vector. There is another way to do it - through the use of an object called an iterator. For now, think of iterators as very sophisticated pointers that can be dereferenced using the * operator, and can be incremented via ++ (plus, plus) and decremented via -- (minus, minus). What we mean by "incrementing" an iterator is that it moves "forward" in a sequence of items stored in a container. For example, if you start 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!