Sintassi:
#include <deque> T& back(); const T& back() const;
La funzione back() ritorna una reference all'ultimo elemento nella deque
Esempio:
deque<int> dq; for( int i = 0; i < 5; i++ ) { dq.push_back(i); } cout << "The first element is " << dq.front() << " and the last element is " << dq.back() << endl;
Produce il seguente output
The first element is 0 and the last element is 4
La funzione back() gira a tempo costante.