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 a new document in OpenOffice Writer, the space between the text and the left, right, top, and bottom of the paper are called ________

A) line breaks B) margins C) tab stops D) sections

Computer Science & Information Technology

________ makes the database unreadable by encrypting the database

A) Password protect B) Make ACCDE C) Digital Signature D) Encryption

Computer Science & Information Technology

Which of the following is the total length of time an essential business function can be unavailable without causing significant harm to the organization?

A. Maximum tolerable downtime B. Maximum tolerable uptime C. Recovery time objective D. Recovery point objective

Computer Science & Information Technology

A virtual machine can't share the use of a network adapter with the host.

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

Computer Science & Information Technology