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...

Form information is secure when sent via e-mail

Indicate whether the statement is true or false

Computer Science & Information Technology

What type of RAID is a striped set of disks that mirror another set of striped disks?

A) 0 B) 1 C) 01 D) 10 E) 5

Computer Science & Information Technology