Std::vector::size
Jump to navigation
Jump to search
Syntax
size_type size() const;
Description
Return size
Returns the number of elements in the vector.
This is the number of actual objects held in the vector, which is not necessarily equal to its storage capacity.
Parameters
none
Return Value
The number of elements in the container.
Member type size_type is an unsigned integral type.
Example
The above example will output 5.
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<int> tab(5);
cout << tab.size() << endl;
return 0;
}