std::vector::push_back – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
|
|
||
|
|
(seit C++11) | |
Hängt den gegebenen Element value an das Ende des Behälters .
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.
Parameter
| value | - | der Wert des Elements, anzuhängen Original: the value of the element to append The text has been machine-translated via Google Translate. |
Anforderungen
1)
value wird CopyInsertable sein
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 wird MoveInsertable sein
Original:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Rückgabewert
(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Komplexität
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.
Beispiel
Der folgende Code verwendet push_back mehrere Zahlen zu einem std::vector<int> hinzu:
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:
Siehe auch
None
baut Elemente-Platz am Ende Original: constructs elements in-place at the end The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |
entfernt das letzte Element Original: removes the last element The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |