◐ Shell
clean mode source ↗

std::vector::size – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

Returns the number of elements in the container, i.e. std::distance(begin(), end()).

Parameter

(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.

Rückgabewert

die Anzahl der Elemente in dem Behälter

Original:

the number of elements 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.

Ausnahmen

Komplexität

Constant

Beispiel

The following code uses size to display the number of elements in a std::vector<int>:

#include <vector>
#include <iostream>
 
int main()
{
    std::vector<int> nums {1, 3, 5, 7};
 
    std::cout << "nums contains " << nums.size() << " elements.\n";
}

Output:

nums contains 4 elements.

Siehe auch

gibt die Anzahl der Elemente, die in derzeit zugewiesenen Speicher gehalten werden kann

Original:

returns the number of elements that can be held in currently allocated storage

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(öffentliche Elementfunktion) [edit]

prüft, ob der Container leer ist

Original:

checks whether the container is empty

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(öffentliche Elementfunktion) [edit]

gibt die maximal mögliche Anzahl von Elementen

Original:

returns the maximum possible number of elements

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(öffentliche Elementfunktion) [edit]
ändert die Anzahl der gespeicherten Elemente
(öffentliche Elementfunktion) [edit]