queue::front
Kuyruğun önüne ilk öğeye başvuru döndürür.
reference front( );
const_reference front( ) const;
Dönüş Değeri
Sıra ilk öğe.Sıra boş ise, dönüş değeri tanımlı değil.
Notlar
Dönüş değeri front için atanmış bir const_reference, sıra nesnesi değiştirilemez.Dönüş değeri front için atanmış bir başvuru, sıra nesnesinin değiştirilebilir.
Üye işlevi döndüren bir başvuru kontrollü sırası ilk öğe için hangi olmalıdır boş olmayan.
Öğe boş bir sıra erişmeye çalışırsanız, 1 _secure_scl ile derlerken, çalışma zamanı hatası ortaya çıkar.Daha fazla bilgi için bkz. İşaretli Yineleyiciler.
Örnek
// queue_front.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>
int main() {
using namespace std;
queue <int> q1;
q1.push( 10 );
q1.push( 20 );
q1.push( 30 );
queue <int>::size_type i;
i = q1.size( );
cout << "The queue length is " << i << "." << endl;
int& ii = q1.back( );
int& iii = q1.front( );
cout << "The integer at the back of queue q1 is " << ii
<< "." << endl;
cout << "The integer at the front of queue q1 is " << iii
<< "." << endl;
}
Çıktı
The queue length is 3.
The integer at the back of queue q1 is 30.
The integer at the front of queue q1 is 10.
Gereksinimler
Başlık: <queue>
Namespace: std