cbegin function in c++ is used to return a constant iterator pointing the first element in an unordered map.
Syntax:
unordered_map.cbegin()
Parameter: It takes an optional parameter
N. If set, the iterator returned will point to the first element of the bucket otherwise it point to the first element of the container.
Return values: A constant iterator pointing to the first element of the unordered_map.
Below program illustrate the working of
cbegin function:
Output:
Contents of the unordered_map :
s==>>5
k==>>4
g==>>1
e==>>2
The cbegin() function returns a constant iterator. If we try to change value, we get compiler error.