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

What will be an ideal response?


They all evaluate to the last element of the container. The first expression
gives the vector the largest legal index, producing the last element. The second
expression returns the back element. The third starts with an iterator one past the end,
and move one towards the front. Dereferencing give the last element. The next
expression begins with an iterator to the first element, adds one less than the size,
giving an iterator to the last element. Dereferencing gives the last element. Finally,
the rbegin() member returns an iterator to the last element (the beginning
element in reverse traversal of the vector elements). Dereferencing gives the last
element.

Computer Science & Information Technology

You might also like to view...

Explain how activation records and the program stack are used to manage the invocation of and return from methods.

What will be an ideal response?

Computer Science & Information Technology

Visit at least three Web sites to learn more about agile system development and spiral models. Prepare a list of the sites you visited and a summary of the results.

What will be an ideal response?

Computer Science & Information Technology

Create a method that draws bars across the current picture using thick lines.

What will be an ideal response?

Computer Science & Information Technology

A ________ data table has input values that are listed either as column-oriented or row-oriented

A) two-variable B) pre-formatted C) one-variable D) custom

Computer Science & Information Technology