back
Syntax:
  #include <queue>
  TYPE& back();
  const TYPE& back() const;

The back() function returns a reference to the last element in the queue.

For example:

 queue<int> q;
 for( int i = 0; i < 5; i++ ) {
   q.push(i);
 }
 cout << "The first element is " << q.front()
      << " and the last element is " << q.back() << endl;           

This code produces the following output:

 The first element is 0 and the last element is 4               

The back() function runs in constant time.