std::vector::push_back - cppreference.com
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. |
<metanoindex/>
<tbody> </tbody>
|
|
||
|
|
(dal C++11) | |
Aggiunge il value dato elemento alla fine del contenitore.
Original:
Appends the given element value to the end of the container.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise no iterators and references are invalidated.
Parametri
| value | - | il valore dell'elemento da aggiungere Original: the value of the element to append The text has been machine-translated via Google Translate. |
Requisiti
1)
value è CopyInsertable essere
Original:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
value è MoveInsertable essere
Original:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Valore di ritorno
(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.
Complessità
Costante.
Original:
Constant.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Esempio
Il codice seguente utilizza push_back per aggiungere interi diversi a un std::vector<int>:
Original:
The following code uses push_back to add several integers to a std::vector<int>:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <vector> #include <iostream> int main() { std::vector<int> numbers; numbers.push_back(42); numbers.push_back(314159); for (int i : numbers) { // c++11 range-based for loop std::cout << i << '\n'; } return 0; }
Output:
Vedi anche
None
costruisce elementi in-posto alla fine Original: constructs elements in-place at the end The text has been machine-translated via Google Translate. (metodo pubblico) [modifica] | |
rimuove l'ultimo elemento Original: removes the last element The text has been machine-translated via Google Translate. (metodo pubblico) [modifica] | |