forked from Bhupesh-V/30-seconds-of-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18ec9cd
commit b1a53cb
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# cbgin | ||
|
||
**Description** : The function returns an iterator which is used to iterate container. | ||
|
||
Notes: | ||
|
||
1. The iterator points to the beginning of the vector. | ||
2. Iterator cannot modify the contents of the vector. | ||
|
||
**Example**: | ||
```cpp | ||
// Demonstrates cbegin() | ||
#include <iostream> | ||
#include <vector> | ||
|
||
int main(){ | ||
//declares an empty vector | ||
std::vector<int> vec; | ||
|
||
//inserting elements in vector | ||
vec.push_back(101); | ||
vec.push_back(12); | ||
vec.push_back(999); | ||
|
||
//Displaying elements of vector | ||
std::cout << "Content of the vector \n"; | ||
for (auto it = vec.cbegin(); it != vec.end(); ++it){ | ||
std::cout << *it << '\n'; | ||
} | ||
return 0; | ||
} | ||
|
||
``` | ||
**[Run Code](https://rextester.com/XRFTW94461)** | ||
|