Javatpoint Logo
Javatpoint Logo

C++ multiset cbegin()

C++ multiset cbegin() function is used to return a constant iterator pointing to the first element of the multiset container.

Syntax

A const_iterator is an iterator that points to constant content.

Parameter

None

Return value

The cbegin() funtion returns a const_iterator pointing to the first element of the multiset.

Complexity

Constant

Iterator validity

No changes.

Data Races

The container is accessed.

Concurrently accessing the elements of a multiset container is safe.

Exception Safety

This member function never throws exception.

Example 1

Let's see the simple example for cbegin() function:

Output:

C
C++
Java
SQL

In the above example, cbegin() function is used to return a constant iterator pointing to the first element in the mymultiset multiset.

Example 2

Let's see a simple example:

Output:

The first element of s1 is 1
The first element of s1 is now 2

Example 3

Let's see a simple example to iterate over the multiset using while loop:

Output:

Dolly
John
Nikita
Nikita
Robin

In the above example, cbegin() function is used to return an iterator pointing to the first element in the mymultiset multiset.

Example 4

Let's see another simple example:

Output:

Increasing order: 
______________________
290
350
400
400
410
465

Smallest Number is: 290
Biggest Number is: 465

In the above example, cbegin() function is used to return an iterator pointing to the first element in the mymultiset multiset.

Next TopicC++ multiset





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA