ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.2 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://iq.opengenus.org/different-ways-to-initialize-queue-cpp/ |
| Last Crawled | 2026-04-03 05:29:42 (5 days ago) |
| First Indexed | 2020-04-24 11:21:18 (5 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Different ways to initialize a queue in C++ STL |
| Meta Description | In this article, we have explored different ways to initialize a queue in C++ Standard Template Library (STL). There are three ways to initialize Member functions for inserting elements, Container objects and another Queue. |
| Meta Canonical | null |
| Boilerpipe Text | In this article, we have explored different ways to initialize a queue in
C++
Standard Template Library (STL)
. There are three ways to initialize:
Member functions for inserting elements
Container objects
Another Queue
Before moving into the details of initialization, we will go through the basic knowledge of queue in C++ STL.
A Queue is a data structure that implements the First In First Out(FIFO) principle i.e the first element going into the queue is the first element to be taken out. You can visualize it exactly like a 'disciplined' queue in a market. A queue has 2 ends: front and back. Elements to be added to the queue are inserted from the back of the queue whereas elements are removed from the front of the queue.
Such is the structure of a queue:
The C++ STL provides 10 Container classes that have member functions that can be used to manipulate the data.
Types of Containers are:
First-class Containers/Sequence Containers
: Include vector, deque and list
Associative Containers
: Include set, map, Multiset and Multimap
Container adaptors/Derived Containers
: Include Queue, Stack, Priority queue
To know more about Containers,visit:
this link
All Container adaptors internally use
suitably modified
first-class Containers such that they achieve the desired functionality.
Introduction
Queue is a Container adaptor that can be used whenever a standard queue is required in the program. It does not have any special iterators of it's own(Iterators are components of STL, used to traverse Containers). It can use the first class container objects for its initialization. A queue is declared as follows:
queue<int> q; // template<class T> identifier;
During declaration, the base container of the queue can also be explicitly mentioned:
template<class T,class Container> identifier
Generally, a queue implements deque as its default base container.
queue<int , deque<int> > q1;
However, one can easily change the base container by simply mentioning the name of the desired base container in the declaration of the queue. Just like this:
queue<int , list<int> >q2;
The above mentioned two examples create an empty queue with deque and list as the base container, respectively.
A queue can be initialized to the values of an existing
list
or
deque
.
Queue cannot be initialized to vectors as the vector class does not support the pop() function and hence removing elements from the queue is not possible which hinders its functionality and dissolves its purpose.
Queue can be initialized using:
Member functions for inserting elements
Container objects
Another Queue
Let's discuss each of them :
1.Inserting elements using member functions
This is the most trivial method for initializing a queue.Elements are simply inserted into the queue using the push() member function. Another member function called emplace() can also be used. Just like push(),emplace() inserts elements at the end of the queue.
Following is an example :
#include<iostream>
#include<queue>
using namespace std;
int main()
{
queue<int> q;
q.push(1);
q.push(4);
q.push(9);
q.push(16);
q.push(25);
while(!q.empty())
{
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
Output
1 4 9 16 25
2. Container objects
Objects of first-class Containers like deque and list are used to initialize a queue.
Example
#include <iostream>
#include <queue>
#include <deque>
using namespace std;
int main(){
deque<int> dq ;
for(int i=1;i<=5;i++)
dq.push_back(i); //inserting 5 elements in the deque
queue<int> q(dq); //initializing q using dq
q.push(10);
q.pop();
while(!q.empty()){
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
Output
2 3 4 5 10
This example initializes a queue (q) with a deque (dq) containing 5 elements.
Similarly,a queue can be initialized using a list. Here, a queue (q) is initialized using a list (lt).
Example
#include <iostream>
#include <list>
#include <queue>
using namespace std;
int main()
{
list<int> lt(5,10); // initializing a list with 5 elements
queue<int,list<int> > q(lt); // q is initialized to the values of the list
while(!q.empty())
{
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
Output
10 10 10 10 10
3. Another Queue
Another queue of the
same data type and base container
can be used to initialize a queue. Simply pass the queue, just like a constructor parameter.
Example
#include <iostream>
#include <queue>
using namespace std;
int main()
{
queue<int> past;
past.push(10);
past.push(20);
past.push(30);
queue<int> present(past); //present is initialized to past
while(!present.empty()){
cout<<present.front()<<" ";
present.pop();
}
return 0;
}
Output
10 20 30
Complexity
of initialization of a queue is O(n)
Question
Which one of the following is not a member function of the queue STL class?
get(int i)
swap()
emplace()
back()
get(int) is used for accessing elements in Hashmaps,Arraylists in java etc.
All other options are member functions of the Queue container in c++ stl.
1) swap() is used to swap elements of 2 queues
2) emplace() is used to insert elements at the end of the queue
3) back() is used to get a reference to the last element in the queue |
| Markdown | \×
[Home](http://iq.opengenus.org/) [Discussions](http://discourse.opengenus.org/) [Write at Opengenus IQ](http://iq.opengenus.org/guide-to-writing-a-note-at-opengenus-iq/)
\×
☰
- [DSA Cheatsheet](https://amzn.to/4arEtct)
- [HOME](https://iq.opengenus.org/)
- [Track your progress](https://iq.opengenus.org/100-interview-problems/)
- [Deep Learning (FREE)](https://iq.opengenus.org/deep-learning-checklist/)
- [Join our Internship 🎓](https://discourse.opengenus.org/t/internship-guidelines-at-opengenus/2335/)
- [RANDOM](https://iq.opengenus.org/random/)
- [One Liner](https://iq.opengenus.org/one/)
×
Search anything:
Interesting posts
- [Top Competitive Programmers](https://iq.opengenus.org/best-competitive-programmers/)
- [Unsolved Problems in Algorithms](https://iq.opengenus.org/unsolved-problems-in-algorithms/)
- [Top patent holders in India](https://iq.opengenus.org/top-patent-person-in-india/)
- [How to get Developer Job in Japan?](https://iq.opengenus.org/get-developer-job-in-japan/)
- [\[INTERNSHIP\]](http://internship.opengenus.org/)
- [STORY: Most Profitable Software Patents](https://iq.opengenus.org/most-profitable-software-patents/)
- [How to earn by filing Patents?](https://iq.opengenus.org/earn-by-filing-patents/)
- [Richest Programmers in the World](https://iq.opengenus.org/richest-programmers-in-the-world/)
- [STORY: Multiplication from 1950 to 2022](https://iq.opengenus.org/evolution-of-integer-multiplication/)
- [Position of India at ICPC World Finals (1999 to 2021)](https://iq.opengenus.org/position-of-india-in-icpc/)
- [Most Dangerous Line of Code 💀](https://iq.opengenus.org/most-dangerous-line-of-code/)
- [Age of All Programming Languages](https://iq.opengenus.org/age-of-programming-languages/)
- [How to earn money online as a Programmer?](https://iq.opengenus.org/earn-money-online-as-programmer/)
- [STORY: Kolmogorov N^2 Conjecture Disproved](https://iq.opengenus.org/kolmogorov-n2-conjecture/)
- [STORY: man who refused \$1M for his discovery](https://iq.opengenus.org/grigori-perelman/)
- [STORY: Man behind VIM](https://iq.opengenus.org/bram-moolenaar/)
- [STORY: Galactic algorithm](https://iq.opengenus.org/galactic-algorithm/)
- [STORY: Inventor of Linked List](https://iq.opengenus.org/inventor-of-linked-list/)
- [Practice Interview Questions](https://iq.opengenus.org/tag/questions/)
- [List of 50+ Binary Tree Problems](https://iq.opengenus.org/list-of-binary-tree-problems/)
- [List of 100+ Dynamic Programming Problems](https://iq.opengenus.org/list-of-dynamic-programming-problems/)
- [List of 50+ Array Problems](https://iq.opengenus.org/list-of-array-problems/)
- [11 Greedy Algorithm Problems \[MUST\]](https://iq.opengenus.org/greedy-algorithms-you-must-attempt/)
- [List of 50+ Linked List Problems](https://iq.opengenus.org/list-of-linked-list-problems/)
- [100+ Graph Algorithms and Techniques](https://iq.opengenus.org/list-of-graph-algorithms/)
Software Engineering tutorial
- [Unleashing the Power of .td Files: TableGen](https://iq.opengenus.org/td-files-tablegen/)
- [A Beginner's Guide to Kubernetes](https://iq.opengenus.org/beginners-guide-to-kubernetes/)
- [Light as a Feather: The Art of the Flyweight Pattern](https://iq.opengenus.org/flyweight-pattern/)
- [The Intersection of Bitcoin and Online Casinos: A Technological Revolution](https://iq.opengenus.org/intersection-of-bitcoin-and-online-casinos/)
- [Comparing Different Programming Languages](https://iq.opengenus.org/comparing-different-programming-languages/)
- [Analog voice-based media storage for compressed data transfer of images post-encryption](https://iq.opengenus.org/analog-voice-based-media-storage/)
- [Wirth's Law: Optimizing Software for Virtual Memory](https://iq.opengenus.org/wirth-law/)
- [Write through and write back](https://iq.opengenus.org/write-through-and-write-back/)
- [The Integration of Security to DevOps](https://iq.opengenus.org/the-integration-of-security-to-devops/)
- [AI and Machine Learning in Automated Cross Browser Testing](https://iq.opengenus.org/ai-and-machine-learning-in-automated-cross-browser-testing/)
- [Hоw Dо Yоu Justify the Vаlue оf Sоftwаre Testing tо Clients?](https://iq.opengenus.org/how-do-you-justify-the-value-of-software-testing-to-clients/)
- [How Can You Find the Best Online Platform for Software Testing Communities?](https://iq.opengenus.org/how-can-you-find-the-best-online-platform-for-software-testing-communities/)
- [Amdahl’s law](https://iq.opengenus.org/amdahls-law/)
- [Trading Application in C++ \[Software Development Project with source code\]](https://iq.opengenus.org/trading-application-in-cpp/)
- [25 Software Development Project Ideas](https://iq.opengenus.org/software-development-project-ideas/)
- [Dynamic and Static dispatch in C++](https://iq.opengenus.org/dynamic-and-static-dispatch-in-cpp/)
- [Adding Numbers with Linked Lists in C++](https://iq.opengenus.org/add-2-numbers-in-linked-list-in-cpp/)
- [Boost Program Options](https://iq.opengenus.org/boost-program-options/)
- [Creating UPD Asynchronous Client Server in C++ using Boost.Asio](https://iq.opengenus.org/upd-asynchronous-client-server-in-cpp-boost-asio/)
- [Creating TCP Asynchronous Client Server in C++ using Boost.Asio](https://iq.opengenus.org/tcp-asynchronous-client-server-in-cpp-boost-asio/)
- [Basics of C++ Boost.ASIO](https://iq.opengenus.org/basics-of-cpp-boost-asio/)
- [Smart pointers in C++](https://iq.opengenus.org/smart-pointers-in-cpp/)
- [nth\_element in C++ STL](https://iq.opengenus.org/nth-element-in-cpp-stl/)
- [Queue::emplace in C++ STL](https://iq.opengenus.org/queue-emplace-in-cpp/)
- [Different Ways to Delete Elements in Unordered Map in C++ STL](https://iq.opengenus.org/delete-elements-in-unordered-map-in-cpp-stl/)
- [Vector of array in C++](https://iq.opengenus.org/vector-of-array-in-cpp/)
- [How to Use Friend Classes in C++ to Access Private and Protected Members](https://iq.opengenus.org/how-to-use-friend-classes-in-cpp-to-access-private-and-protected-members/)
- [Lazy initialization in C++](https://iq.opengenus.org/lazy-initialization-in-cpp/)
- [Bank Management System in C++ \[Project with source code\]](https://iq.opengenus.org/bank-management-system-in-cpp/)
- [50 Interview questions on C++ Struct](https://iq.opengenus.org/interview-questions-on-cpp-struct/)
# Different ways to initialize a queue in C++ STL
#### [Software Engineering](https://iq.opengenus.org/tag/software-engineering/ "Software Engineering") [C++](https://iq.opengenus.org/tag/cpp/ "C++")
More
Less
Up
[](https://amzn.to/3EgiXLM)
[Open-Source Internship opportunity by OpenGenus for programmers. Apply now.](http://internship.opengenus.org/)
In this article, we have explored different ways to initialize a queue in [C++](https://iq.opengenus.org/tag/cpp/) [Standard Template Library (STL)](https://iq.opengenus.org/tag/standard-template-library/). There are three ways to initialize:
1. Member functions for inserting elements
2. Container objects
3. Another Queue
Before moving into the details of initialization, we will go through the basic knowledge of queue in C++ STL.
A Queue is a data structure that implements the First In First Out(FIFO) principle i.e the first element going into the queue is the first element to be taken out. You can visualize it exactly like a 'disciplined' queue in a market. A queue has 2 ends: front and back. Elements to be added to the queue are inserted from the back of the queue whereas elements are removed from the front of the queue.
Such is the structure of a queue:

The C++ STL provides 10 Container classes that have member functions that can be used to manipulate the data.
Types of Containers are:
1. *First-class Containers/Sequence Containers*: Include vector, deque and list
2. *Associative Containers* : Include set, map, Multiset and Multimap
3. *Container adaptors/Derived Containers* : Include Queue, Stack, Priority queue
To know more about Containers,visit: [this link](http://cs.stmarys.ca/~porter/csc/ref/stl/containers_summary.html)
All Container adaptors internally use *suitably modified* first-class Containers such that they achieve the desired functionality.
# Introduction
Queue is a Container adaptor that can be used whenever a standard queue is required in the program. It does not have any special iterators of it's own(Iterators are components of STL, used to traverse Containers). It can use the first class container objects for its initialization. A queue is declared as follows:
```
queue<int> q; // template<class T> identifier;
```
During declaration, the base container of the queue can also be explicitly mentioned: *template\<class T,class Container\> identifier*
Generally, a queue implements deque as its default base container.
```
queue<int , deque<int> > q1;
```
However, one can easily change the base container by simply mentioning the name of the desired base container in the declaration of the queue. Just like this:
```
queue<int , list<int> >q2;
```
The above mentioned two examples create an empty queue with deque and list as the base container, respectively.
A queue can be initialized to the values of an existing **list** or **deque**.
Queue cannot be initialized to vectors as the vector class does not support the pop() function and hence removing elements from the queue is not possible which hinders its functionality and dissolves its purpose.
## Queue can be initialized using:
1. Member functions for inserting elements
2. Container objects
3. Another Queue
Let's discuss each of them :
# 1\.Inserting elements using member functions
This is the most trivial method for initializing a queue.Elements are simply inserted into the queue using the push() member function. Another member function called emplace() can also be used. Just like push(),emplace() inserts elements at the end of the queue. **Following is an example :**
```
#include<iostream>
#include<queue>
using namespace std;
int main()
{
queue<int> q;
q.push(1);
q.push(4);
q.push(9);
q.push(16);
q.push(25);
while(!q.empty())
{
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
```
**Output**
```
1 4 9 16 25
```
# 2\. Container objects
Objects of first-class Containers like deque and list are used to initialize a queue.
**Example**
```
#include <iostream>
#include <queue>
#include <deque>
using namespace std;
int main(){
deque<int> dq ;
for(int i=1;i<=5;i++)
dq.push_back(i); //inserting 5 elements in the deque
queue<int> q(dq); //initializing q using dq
q.push(10);
q.pop();
while(!q.empty()){
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
```
**Output**
```
2 3 4 5 10
```
This example initializes a queue (q) with a deque (dq) containing 5 elements.
Similarly,a queue can be initialized using a list. Here, a queue (q) is initialized using a list (lt).
**Example**
```
#include <iostream>
#include <list>
#include <queue>
using namespace std;
int main()
{
list<int> lt(5,10); // initializing a list with 5 elements
queue<int,list<int> > q(lt); // q is initialized to the values of the list
while(!q.empty())
{
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
```
**Output**
```
10 10 10 10 10
```
# 3\. Another Queue
Another queue of the **same data type and base container** can be used to initialize a queue. Simply pass the queue, just like a constructor parameter.
**Example**
```
#include <iostream>
#include <queue>
using namespace std;
int main()
{
queue<int> past;
past.push(10);
past.push(20);
past.push(30);
queue<int> present(past); //present is initialized to past
while(!present.empty()){
cout<<present.front()<<" ";
present.pop();
}
return 0;
}
```
**Output**
```
10 20 30
```
## ***Complexity** of initialization of a queue is O(n)*
## Question
#### Which one of the following is not a member function of the queue STL class?
######
get(int i)
swap()
emplace()
back()
get(int) is used for accessing elements in Hashmaps,Arraylists in java etc.
All other options are member functions of the Queue container in c++ stl.
1) swap() is used to swap elements of 2 queues
2) emplace() is used to insert elements at the end of the queue
3) back() is used to get a reference to the last element in the queue
#### [Tushti](https://iq.opengenus.org/author/tushti/)
Read [more posts](https://iq.opengenus.org/author/tushti/) by this author.
[Read More](https://iq.opengenus.org/author/tushti/)
Improved & Reviewed by:
[ OpenGenus Tech Review Team](https://iq.opengenus.org/author/opengenus/ "OpenGenus Tech Review Team")
— OpenGenus IQ: Learn Algorithms, DL, System Design —
### [Software Engineering](https://iq.opengenus.org/tag/software-engineering/)
- [Blockchain Nodes Demystified: A Technical Overview](https://iq.opengenus.org/blockchain-nodes-demystified-a-technical-overview/)
- [Understanding Linux Namespaces: The Building Blocks of Containerization](https://iq.opengenus.org/linux-namespaces/)
- [Goals of Network Security](https://iq.opengenus.org/goals-of-network-security/)
[See all 1277 posts →](https://iq.opengenus.org/tag/software-engineering/)
[Algorithms Run Length Encoding Learn more about Run Length encoding which is a lossless data compression algorithm, supported by many bitmap file formats. In short, it picks the next unique character and appends the character and it’s count of subsequent occurrences in the encoded string.](https://iq.opengenus.org/run-length-encoding/)
[Sonali Singhal](https://iq.opengenus.org/author/sonali/)
[Algorithms Breadth first search (BFS) Breadth first search (BFS) is one of the most used graph traversal techniques where nodes at the same level are traversed first before going into the next level. Queue is used internally in its implementation.](https://iq.opengenus.org/bfs-graph-traversal/)
 [Sourajeet Mohanty](https://iq.opengenus.org/author/sourajeet/)
[ OpenGenus IQ: Learn Algorithms, DL, System Design](https://iq.opengenus.org/)
—
Different ways to initialize a queue in C++ STL
Share this
[OpenGenus IQ](https://iq.opengenus.org/) © 2026 All rights reserved ™
Contact - Email: [team@opengenus.org](mailto:team@opengenus.org)
Primary Address: JR Shinjuku Miraina Tower, Tokyo, Shinjuku 160-0022, JP
Office \#2: Commercial Complex D4, Delhi, Delhi 110017, IN
[Top Posts](https://iq.opengenus.org/) [LinkedIn](https://www.linkedin.com/company/opengenus) [Twitter](https://twitter.com/OpenGenus)
[Android App](https://play.google.com/store/apps/details?id=com.og.opengenus&hl=en&gl=US)
[Apply for Internship](http://internship.opengenus.org/) |
| Readable Markdown | In this article, we have explored different ways to initialize a queue in [C++](https://iq.opengenus.org/tag/cpp/) [Standard Template Library (STL)](https://iq.opengenus.org/tag/standard-template-library/). There are three ways to initialize:
1. Member functions for inserting elements
2. Container objects
3. Another Queue
Before moving into the details of initialization, we will go through the basic knowledge of queue in C++ STL.
A Queue is a data structure that implements the First In First Out(FIFO) principle i.e the first element going into the queue is the first element to be taken out. You can visualize it exactly like a 'disciplined' queue in a market. A queue has 2 ends: front and back. Elements to be added to the queue are inserted from the back of the queue whereas elements are removed from the front of the queue.
Such is the structure of a queue:

The C++ STL provides 10 Container classes that have member functions that can be used to manipulate the data.
Types of Containers are:
1. *First-class Containers/Sequence Containers*: Include vector, deque and list
2. *Associative Containers* : Include set, map, Multiset and Multimap
3. *Container adaptors/Derived Containers* : Include Queue, Stack, Priority queue
To know more about Containers,visit: [this link](http://cs.stmarys.ca/~porter/csc/ref/stl/containers_summary.html)
All Container adaptors internally use *suitably modified* first-class Containers such that they achieve the desired functionality.
## Introduction
Queue is a Container adaptor that can be used whenever a standard queue is required in the program. It does not have any special iterators of it's own(Iterators are components of STL, used to traverse Containers). It can use the first class container objects for its initialization. A queue is declared as follows:
```
queue<int> q; // template<class T> identifier;
```
During declaration, the base container of the queue can also be explicitly mentioned: *template\<class T,class Container\> identifier*
Generally, a queue implements deque as its default base container.
```
queue<int , deque<int> > q1;
```
However, one can easily change the base container by simply mentioning the name of the desired base container in the declaration of the queue. Just like this:
```
queue<int , list<int> >q2;
```
The above mentioned two examples create an empty queue with deque and list as the base container, respectively.
A queue can be initialized to the values of an existing **list** or **deque**.
Queue cannot be initialized to vectors as the vector class does not support the pop() function and hence removing elements from the queue is not possible which hinders its functionality and dissolves its purpose.
## Queue can be initialized using:
1. Member functions for inserting elements
2. Container objects
3. Another Queue
Let's discuss each of them :
## 1\.Inserting elements using member functions
This is the most trivial method for initializing a queue.Elements are simply inserted into the queue using the push() member function. Another member function called emplace() can also be used. Just like push(),emplace() inserts elements at the end of the queue. **Following is an example :**
```
#include<iostream>
#include<queue>
using namespace std;
int main()
{
queue<int> q;
q.push(1);
q.push(4);
q.push(9);
q.push(16);
q.push(25);
while(!q.empty())
{
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
```
**Output**
```
1 4 9 16 25
```
## 2\. Container objects
Objects of first-class Containers like deque and list are used to initialize a queue.
**Example**
```
#include <iostream>
#include <queue>
#include <deque>
using namespace std;
int main(){
deque<int> dq ;
for(int i=1;i<=5;i++)
dq.push_back(i); //inserting 5 elements in the deque
queue<int> q(dq); //initializing q using dq
q.push(10);
q.pop();
while(!q.empty()){
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
```
**Output**
```
2 3 4 5 10
```
This example initializes a queue (q) with a deque (dq) containing 5 elements.
Similarly,a queue can be initialized using a list. Here, a queue (q) is initialized using a list (lt).
**Example**
```
#include <iostream>
#include <list>
#include <queue>
using namespace std;
int main()
{
list<int> lt(5,10); // initializing a list with 5 elements
queue<int,list<int> > q(lt); // q is initialized to the values of the list
while(!q.empty())
{
cout<<q.front()<<" ";
q.pop();
}
return 0;
}
```
**Output**
```
10 10 10 10 10
```
## 3\. Another Queue
Another queue of the **same data type and base container** can be used to initialize a queue. Simply pass the queue, just like a constructor parameter.
**Example**
```
#include <iostream>
#include <queue>
using namespace std;
int main()
{
queue<int> past;
past.push(10);
past.push(20);
past.push(30);
queue<int> present(past); //present is initialized to past
while(!present.empty()){
cout<<present.front()<<" ";
present.pop();
}
return 0;
}
```
**Output**
```
10 20 30
```
## ***Complexity** of initialization of a queue is O(n)*
## Question
#### Which one of the following is not a member function of the queue STL class?
get(int i)
swap()
emplace()
back()
get(int) is used for accessing elements in Hashmaps,Arraylists in java etc.
All other options are member functions of the Queue container in c++ stl.
1) swap() is used to swap elements of 2 queues
2) emplace() is used to insert elements at the end of the queue
3) back() is used to get a reference to the last element in the queue |
| Shard | 55 (laksa) |
| Root Hash | 13269647889762130655 |
| Unparsed URL | org,opengenus!iq,/different-ways-to-initialize-queue-cpp/ s443 |