
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
set::begin() and set::end() in C++ STL
Set::begin() function is a bidirectional iterator used to return an iterator pointing to the first element of the set container.
Set::end() function is a bidirectional iterator used to return an iterator pointing to the last element of the set container.
Example Code
#include<iostream> #include <bits/stdc++.h> using namespace std; int main() { set<int> s; set<int>::iterator it; s.insert(7); s.insert(6); s.insert(1); s.insert(4); s.insert(2); s.insert(9); s.insert(10); for (auto it=s.begin(); it != s.end(); ++it) cout << ' ' << *it; return 0; }
Output
1 2 4 6 7 9 10
- Related Articles
- map::begin() and end() in C++ STL
- vector::begin() and vector::end() in C++ STL
- list begin( ) and list end( ) in C++ STL
- forward_list::begin() and forward_list::end() in C++ STL
- deque::begin() and deque::end in C++ STL
- match_results begin() and end() function in C++ STL
- multiset begin() and end() function in C++ STL
- multimap::begin() and multimap::end() in C++ STL
- BEGIN and END Blocks in Perl
- Insertion and Deletion in STL Set C++
- Set get_allocator() in C++ STL
- Set insert() in C++ STL
- set operator= in C++ STL
- Set cbegin() and cend() function in C++ STL
- Set crbegin() and crend() function in C++ STL

Advertisements