Skip to content

Commit

Permalink
Added cbegin of vector
Browse files Browse the repository at this point in the history
  • Loading branch information
khagapati-bagh committed Oct 1, 2019
1 parent 18ec9cd commit b1a53cb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions vector/cbegin.md
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)**

0 comments on commit b1a53cb

Please sign in to comment.