std::vector::front
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
reference front(); | ||
const_reference front()const; | ||
Restituisce un riferimento al primo elemento nel contenitore.
Original:
Returns a reference to the first element in the container.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Chiamare
front
su un contenitore vuoto non è definito.Original:
Calling
front
on an empty container is undefined.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Indice |
[modifica]Parametri
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Valore di ritorno
riferimento al primo elemento
Original:
reference to the first element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Complessità
Constant
Original:
Constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Note
Per un
c
contenitore, il c.front() espressione è equivalente a *c.begin().Original:
For a container
c
, the expression c.front() is equivalent to *c.begin().The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Esempio
Il codice seguente utilizza
front
per visualizzare il primo elemento di un std::vector<char>: Original:
The following code uses
front
to display the first element of a std::vector<char>: The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <vector>#include <iostream> int main(){std::vector<char> letters {'o', 'm', 'g', 'w', 't', 'f'}; if(!letters.empty()){std::cout<<"The first character is: "<< letters.front()<<'\n';}}
Output:
The first character is o
See also
access the last element (metodo pubblico) |