Skip to content

Commit

Permalink
Merge pull request Bhupesh-V#143 from khagapati-bagh/cbegin_vector
Browse files Browse the repository at this point in the history
Added cbegin of vector
  • Loading branch information
Bhupesh-V authored Oct 1, 2019
2 parents c04ec9f + b1a53cb commit 354b47d
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 354b47d

Please sign in to comment.