Suppose we are given an STL vector container named vec that holds values of type double. What do each of vec[0], vec.front(), *(vec.begin()), *(vec.end() – vec.size())and *(vec.rend()-1) mean?

What will be an ideal response?


They all evaluate to the first element of the container. The expression
vec[0] uses index 0 to fetch the first vector element. The expression
vec.front() fetches the front element of vec. The expression
*(vec.end() – vec.size())starts with an iterator past the end, subtracts the
number of elements from this iterator, which results in an iterator to the first element
of the vector. The expression *(vec.rend()-1) starts with an iterator in front
of the first element, then moves one towards the rear (this is a reverse iterator)
resulting in an iterator to the first element of the vector.

Computer Science & Information Technology

You might also like to view...

In the accompanying figure of a feature of Microsoft Excel 2016, the button that Box 1 indicates is used to _____.? ?

A. ?collapse the dialog box B. ?calculate the sum of the two cells C. ?add an absolute reference to the cell D. ?indicate an error

Computer Science & Information Technology

Ink ________ are markings written or drawn directly on slides of a presentation for commentary or explanation

Fill in the blank(s) with correct word

Computer Science & Information Technology

To determine whether an input field is a text box, radio button, check box, etc. use the type property.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which device is used to perform a loopback test on a NIC?

A. Crossover cable B. Link light C. Ephemeral port tester D. Loopback plug

Computer Science & Information Technology