◐ Shell
clean mode source ↗

std::vector::size - 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.

Click here for the English version of this page

<metanoindex/>

<tbody> </tbody>

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

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.

Valore di ritorno

il numero di elementi nel contenitore

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.

Eccezioni

Complessità

Constant

Esempio

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.

Vedi anche

restituisce il numero di elementi che possono essere tenuti in deposito attualmente assegnate

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.


(metodo pubblico) [modifica]

verifica se il contenitore è vuoto

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.


(metodo pubblico) [modifica]

restituisce il massimo numero possibile di elementi

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.


(metodo pubblico) [modifica]
changes the number of elements stored
(metodo pubblico) [modifica]