English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++ The List size() function finds the number of existing elements in the list. This function does not modify the content of the deque.
int size();
It does not contain any parameters.
It returns the number of elements in the list.
Let's see a simple example
#include <iostream> #include<list> using namespace std; int main() { list<int> li={1,2,3}; std::cout << "The size of the list is: " << li.size() << std::endl; return 0; {}
Output:
The size of the list is: 3
In this example, the size() function returns the size of the list, that is3.