C++ multiset begin()C++ multiset begin() function is used to return an iterator referring to the first element of the multiset container. SyntaxParameterNone Return valueIt returns an iterator pointing to the first element of the multiset. ComplexityConstant. Iterator validityNo changes. Data RacesThe container is accessed. Neither the constant nor the non-constant versions modify the container. Exception SafetyThis function never throws exceptions. Example 1Let's see the simple example for begin() function: Output: Contents of mymultiset are: C++ C++ Java SQL In the above example, begin() function is used to return an iterator pointing to the first element in the mymultiset multiset. Example 2Let's see a simple example: Output: 0 2 2 4 5 5 Example 3Let's see a simple example to iterate over the multiset using while loop: Output: Elements of mymultiset are: Aman Deep Nikita Nikita Priya Suman In the above example, begin() function is used to return an iterator pointing to the first element in the mymultiset multiset. Example 4Let's see a simple example: Output: The first element of s1 is 1 The first element of s1 is now 2 In the above example, begin() function is used to return an iterator pointing to the first element in the mymultiset multiset.
Next TopicC++ multiset
|