
- 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
DEQUE CBEGIN() in C++
Given the task is to show the working of deque::cbegin() in C++ STL.
What is Deque::cbegin( ) function?
deque::cbegin() is a function which comes under deque header file, cbegin() returns the iterator pointer which points to the first element of the deque container.
Note − cbegin() function does not have any arguments in it.
Syntax
deq.cbegin();
Where deq is the deque’s object.
Return Value
The function returns a const_iterator.
const_iterator is a random access iterator which is used to point to the first element of the deque container. We can traverse the whole container using the first element of the container, but this can’t be used to do the modifications in the container’s value, but can print the whole container.
Example
#include <deque> #include <iostream> using namespace std; int main(){ deque<int> dqe = { 65, 2, 31, 5, 9 }; // creation of deque cout<<"First element of the deque is: "; cout<<*dqe.cbegin(); // returns first element of deque }
Output
If we run the above code it will generate the following output −
First element of the deque is: 65
Explanation
In this code, 1st of all, the header file contains all the functions of the deque. we have a tendency to declare the deque having some values in it. Then, we have a tendency to print the primary component of the deque exploitation the perform cbegin( ), wherever cbegin( ) is employed to return the primary component of the list.
- Related Articles
- deque::at() and deque::swap() in C++ STL
- deque::begin() and deque::end in C++ STL
- deque::empty() and deque::size() in C++ STL
- deque::operator= and deque::operator[] in C++ STL
- deque front( ) and deque back( ) in C++ in STL
- Deque emplace_front( ) and deque emplace_back( ) in C++ in STL
- forward_list cbegin() in C++ STL
- deque::at() and deque::swap() in C++ programming STL
- Deque in Python
- Deque in Java
- Python - Deque
- DEQUE CRBEGIN() in C++
- Deque interface in Java
- match_results cbegin() add cend() in C++ STL
- deque::push_front() in C++ STL
