
- 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
What is deque back( ) in C++?
The deque back( ) function is used to reference last element of deque.
Syntax
dequename.back( )
Example
Input Deque − 11 12 13 14 15
Output New Deque − 15
Input Deque − C H O I C E
Output New Deque − E
Approach can be followed
First we declare the deque
Then we print the deque.
Then we define the back( ) function.
By using above approach we can fetch the last element of the deque.
Example
// C++ code to demonstrate the working of deque back( ) function #include<iostream.h> #include<deque.h> Using namespace std; int main( ){ // initializing deque deque<int> deque ={ 14, 15, 16, 17, 18 }; cout<< “ Deque: “; for( auto x = deque.begin( ); x != deque.end( ); ++x) cout<< *x << “ “; // defining the back( ) function cout<< deque.back( ); return 0; }
Output
If we run the above code then it will generate the following output
Input: 14 15 16 17 18 Output: 18 Input: S A L T Output: T
- Related Articles
- deque front( ) and deque back( ) in C++ in STL
- What is adam back?
- 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 emplace_front( ) and deque emplace_back( ) in C++ in STL
- deque::at() and deque::swap() in C++ programming STL
- Deque in Python
- Deque in Java
- Python - Deque
- DEQUE CRBEGIN() in C++
- DEQUE CBEGIN() in C++
- Deque interface in Java
- deque::push_front() in C++ STL

Advertisements