unordered_multiset cbegin() function in C++ STL Last Updated : 02 Aug, 2018 Suggest changes Share Like Article Like Report The unordered_multiset::cbegin() is a built-in function in C++ STL which returns a constant iterator pointing to the first element in the container or to the first element in one of its bucket. Syntax: unordered_multiset_name.cbegin(n) Parameters: The function accepts one parameter. If a parameter is passed, it returns a constant iterator pointing to the first element in the bucket. If no parameter is passed, then it returns a constant iterator pointing to the first element in the unordered_multiset container. Return Value: It returns a constant iterator. It cannot be used to change the value of the unordered_multiset element. Below programs illustrates the above function: Program 1: CPP // C++ program to illustrate the // unordered_multiset::cbegin() function #include <bits/stdc++.h> using namespace std; int main() { // declaration unordered_multiset<int> sample; // inserts element sample.insert(10); sample.insert(11); sample.insert(15); sample.insert(13); sample.insert(14); // prints all element cout << "Elements: "; for (auto it = sample.cbegin(); it != sample.cend(); it++) cout << *it << " "; auto it = sample.cbegin(); // print the first element cout << "\nThe first element: " << *it; return 0; } Program 2: CPP // C++ program to illustrate the // unordered_multiset::cbegin() function #include <bits/stdc++.h> using namespace std; int main() { // declaration unordered_multiset<char> sample; // inserts element sample.insert('a'); sample.insert('b'); sample.insert('c'); sample.insert('x'); sample.insert('z'); // print the first element auto it = sample.cbegin(); cout << "The first element: " << *it; it++; cout << "\nThe second element: " << *it; cout << "\nElements: "; // prints all element for (auto it = sample.cbegin(); it != sample.cend(); it++) cout << *it << " "; return 0; } Program 3: CPP // C++ program to illustrate the // unordered_multiset::cbegin() function #include <bits/stdc++.h> using namespace std; int main() { // declaration unordered_multiset<char> sample; // inserts element sample.insert('a'); sample.insert('b'); sample.insert('c'); sample.insert('x'); sample.insert('z'); // print the first element cout << "The first element in first bucket : " << *sample.cbegin(1); cout << "\nElements in first bucket: "; // prints all element for (auto it = sample.cbegin(1); it != sample.cend(1); it++) cout << *it << " "; return 0; } G gopaldave Follow Article Tags : C++ STL CPP-Functions cpp-unordered_multiset Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like