ℹ️ 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 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://www.simplilearn.com/tutorials/cpp-tutorial/queue-in-cpp |
| Last Crawled | 2026-04-16 15:43:17 (23 hours ago) |
| First Indexed | 2021-06-15 13:42:01 (4 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Queue in C++ Function: Syntax, Types And Advantages |
| Meta Description | The queue in C++ is a large data structure. Learn ✅ what queue is? ✅ syntax ✅ examples and ✅ advantages of queue C++ and much more in this tutorial. Start now! |
| Meta Canonical | null |
| Boilerpipe Text | C++ is an extension to
C programming
and is an object-oriented programming language. It, however, has certain features like Friend and Virtual that violate some of the object-oriented programming language features.
C++ is a more robust language than C as it has strong type checking and has features like Encapsulation, Inheritance, and Abstraction. The other features like
Exception Handling
, Operator Overloading, and Function Overloading make it a priority language for developers.
What Is a Queue in C++? Explain With Syntax and an Example
The queue in C++ is a large data structure. Queue in C++ uses an encapsulated object of the sequential container class as its principal container. It provides a particular set of member functions that can access its elements.
Syntax of C++ queue
Template<class T, class Container = deque<T> > class queue;
The insertion of queues in C++ takes place at the rear end, and the deletion takes the front. The rear end or rear element is the last element in the queue. The front or the front element is the element at the first position in the queue.
Queue in C++ works in the “first in first out” technique. It means that the element that you insert first is extracted first, and so on. The queues are indicated as the container adaptors in the application areas.
Every container has support for the main operations list that includes size, pop_front, back, front, push_back, and empty. The different template parameters are:
Container: This argument defines the internal object of the container where all the queue elements are stored.
T: This argument defines the type of element that will be held by the container adaptor.
All Queues must allow:
Enqueue: The addition of an element at the end of the queue.
Dequeue: The removal of an element from the front of the queue.
IsEmpty: The checking of the queue if it is empty.
IsFull: The checking of the queue if it is full.
Peek: Obtaining the value of the front of the queue without removing the element.
Advantages of Queue C++:
It is used in applications in which data is transferred asynchronously between two processes. The queue in C++ can be used for obtaining the synchronization.
The call center systems use queues to hold the incoming calls and to resolve them one by one.
The queues can handle the interrupts in a real-time system and are ideal for disk scheduling and CPU scheduling.
Explain the Various Functions of C++ Queue, With Their Use Cases
The different functions of the queue in C++ are:
Constructor: It is used for the construction of a queue container.
Empty: It is used to test the emptiness of a queue in C++. This function returns true if the queue is empty and returns false if the queue is not empty.
Size: It returns the size of the queue container that is the measure of the number of elements stored in the queue.
Front: It is used to access the front elements of the queue in C++. It is an important queue function in C++ as it is responsible for deletion operations. Elements are deleted from the front.
Back: It is used to access the rear element of the queue in C++. It is an important function as it is responsible for the insertion operations. Elements are added from the front.
Push: It is used to insert a new element at the rear end of the queue in C++.
Pop: It is used to delete a new element at the front end of the queue in C++.
Emplace: It is used for the insertion of the new elements in the queue above the current rear element.
Swap: It is used for interchanging the contents of two containers in the reference.
Relational Operators: It is a non-member function that specifies the relational operators needed for the queues.
Uses allocator <queue>: It is a non-member function that uses the allocator for the queues in C++.
Example of Queue C++ Program Showing the Use of Various Functions:
# include <iostream>
# include <queue>
using namespace std;
void showsg (queue <int> sg)
{
queue <int> ss = sg;
while (!ss.empty())
{
cout << ‘\t’ << ss.front();
ss.pop();
}
cout << ‘\n’;
}
int main()
{
Queue <int> fquiz;
fquiz.push(10);
fquiz.push(20);
fquiz.push(30);
cout << “The queue fquiz is : “;
showsg(fquiz);
cout << “\nfquiz.size() : “ << fquiz.size();
cout << “\nfquiz.front() : “ << fquiz.front();
cout << “\nfquiz.back() : “ << fquiz.back();
cout << “\nfquiz.pop() : “;
fquiz.pop();
showsg(fquiz);
return 0;
}
Output:
Explain the member types of Queue C++, with their use cases
container_type: The underlying container type is specified using the container_type member. It is the second template parameter.
reference: It is a reference type of container member that is usually value_type.
const_reference: It is a reference type of constant container that is usually const value_type.
value_type: This member function specifies the types of the elements.
size_type: This member function specifies the types of the elements.
Example of Queue C++ Program:
# include <iostream>
# include <queue>
using namespace std;
void showsg (queue <int> que)
{
queue <int> sq = que;
while (!sq.empty())
{
cout << ‘\t’ << sq.front();
sq.pop();
}
cout << ‘\n’;
}
int main()
{
queue <int> fquiz;
fquiz.push(11);
fquiz.push(12);
fquiz.push(13);
cout << “Here is the Queue : “;
showQueue(fquiz);
cout << “\nSize of Queue : “ << fquiz.size();
cout << “\nFront of Queue: “ << fquiz.front();
cout << “\nBack of Queue: “ << fquiz.back();
return 0;
}
Output:
Wrapping Up
This article covers all the functions, member types, and examples of Queue in C++. Your search for the best learning about the queue in C++ ends at
Simplilearn
. Along with basic free courses, it offers certified courses to become a
Post Graduate Program In Full Stack Web Development
Learn from the best technical project managers that are seasoned in handling queues in C++.
SkillUp by Simplilearn is an initiative of the company to offer free courses in a variety of IT fields. Reach us to know more about it.
Have any questions regarding this article? Let us know in the comments section, and our experts will answer them for you, ASAP.
Happy learning! |
| Markdown | [](https://www.simplilearn.com/ "Simplilearn - Online Certification Training Course Provider")
All Courses
All Courses
- [For Business](https://www.simplilearn.com/corporate-training "Simplilearn for Business")
- [Resources](https://www.simplilearn.com/tutorials/cpp-tutorial/queue-in-cpp)
- [Free Courses](https://www.simplilearn.com/skillup-free-online-courses "Free Courses")
- [Free Resources](https://www.simplilearn.com/resources "Free Resources")
- [More](https://www.simplilearn.com/tutorials/cpp-tutorial/queue-in-cpp)
- [Reviews](https://www.simplilearn.com/reviews "Reviews")
- [Become a Partner](https://www.simplilearn.com/reseller-partner-program-for-training-courses "Partners")
- [Become an Instructor](https://www.simplilearn.com/become-our-trainer "Become an Instructor")
[Login](https://lms.simplilearn.com/ "Login")
Software Development
[Data Science & Business Analytics](https://www.simplilearn.com/resources/data-science-business-analytics)[AI & Machine Learning](https://www.simplilearn.com/resources/artificial-intelligence-machine-learning)[Project Management](https://www.simplilearn.com/resources/project-management)[Cyber Security](https://www.simplilearn.com/resources/cyber-security)[Cloud Computing](https://www.simplilearn.com/resources/cloud-computing)[DevOps](https://www.simplilearn.com/resources/devops)[Business and Leadership](https://www.simplilearn.com/resources/business-and-leadership)[Quality Management](https://www.simplilearn.com/resources/quality-management)[Software Development](https://www.simplilearn.com/resources/software-development)[Agile and Scrum](https://www.simplilearn.com/resources/agile-and-scrum)[IT Service and Architecture](https://www.simplilearn.com/resources/it-service-management)[Digital Marketing](https://www.simplilearn.com/resources/digital-marketing)[Big Data](https://www.simplilearn.com/resources/big-data-and-analytics)[Career Fast-track](https://www.simplilearn.com/resources/career-fast-track)[Enterprise](https://www.simplilearn.com/resources/enterprise)[Other Segments](https://www.simplilearn.com/resources/other-segments)
[Articles](https://www.simplilearn.com/resources/software-development/articles)[Ebooks](https://www.simplilearn.com/resources/software-development/ebooks)[Free Practice Tests](https://www.simplilearn.com/resources/software-development/free-practice-tests)[On-demand Webinars](https://www.simplilearn.com/resources/software-development/on-demand-webinars)[Tutorials](https://www.simplilearn.com/resources/software-development/tutorials)
Explore our curated learning milestones for you\!
Get Affiliated Certifications with Live Class programs
[View All](https://www.simplilearn.com/courses/software-development/)

C++ Fundamentals
- 24x7 learner assistance and support
[View Program]()
Click here to close suggestions\!
[Home](https://www.simplilearn.com/)[Resources](https://www.simplilearn.com/resources)[Software Development](https://www.simplilearn.com/resources/software-development)Queue in C++ Function: Syntax, Types And Advantages
# Queue in C++ Function: Syntax, Types And Advantages
[By Simplilearn](https://www.simplilearn.com/authors/simplilearn)
Share This Article:
Last updated on Nov 18, 202513714

C++ is an extension to [C programming](https://www.simplilearn.com/c-programming-article "C programming") and is an object-oriented programming language. It, however, has certain features like Friend and Virtual that violate some of the object-oriented programming language features.
C++ is a more robust language than C as it has strong type checking and has features like Encapsulation, Inheritance, and Abstraction. The other features like [Exception Handling](https://www.simplilearn.com/tutorials/cpp-tutorial/exception-handling-in-cpp "Exception Handling"), Operator Overloading, and Function Overloading make it a priority language for developers.
## What Is a Queue in C++? Explain With Syntax and an Example
The queue in C++ is a large data structure. Queue in C++ uses an encapsulated object of the sequential container class as its principal container. It provides a particular set of member functions that can access its elements.
Want a Top Software Development Job? Start Here\!AI-Powered Full Stack Developer Program[Explore Program](https://www.simplilearn.com/full-stack-developer-course-mern-certification-training?source=GhPreviewCTABanner)

### Syntax of C++ queue
Template\<class T, class Container = deque\<T\> \> class queue;
The insertion of queues in C++ takes place at the rear end, and the deletion takes the front. The rear end or rear element is the last element in the queue. The front or the front element is the element at the first position in the queue.
Queue in C++ works in the “first in first out” technique. It means that the element that you insert first is extracted first, and so on. The queues are indicated as the container adaptors in the application areas.
Every container has support for the main operations list that includes size, pop\_front, back, front, push\_back, and empty. The different template parameters are:
- Container: This argument defines the internal object of the container where all the queue elements are stored.
- T: This argument defines the type of element that will be held by the container adaptor.
### All Queues must allow:
- Enqueue: The addition of an element at the end of the queue.
- Dequeue: The removal of an element from the front of the queue.
- IsEmpty: The checking of the queue if it is empty.
- IsFull: The checking of the queue if it is full.
- Peek: Obtaining the value of the front of the queue without removing the element.
### Advantages of Queue C++:
- It is used in applications in which data is transferred asynchronously between two processes. The queue in C++ can be used for obtaining the synchronization.
- The call center systems use queues to hold the incoming calls and to resolve them one by one.
- The queues can handle the interrupts in a real-time system and are ideal for disk scheduling and CPU scheduling.
Want a Top Software Development Job? Start Here\!AI-Powered Full Stack Developer Program[Explore Program](https://www.simplilearn.com/full-stack-developer-course-mern-certification-training?source=GhPreviewCTABanner)

## Explain the Various Functions of C++ Queue, With Their Use Cases
The different functions of the queue in C++ are:
- Constructor: It is used for the construction of a queue container.
- Empty: It is used to test the emptiness of a queue in C++. This function returns true if the queue is empty and returns false if the queue is not empty.
- Size: It returns the size of the queue container that is the measure of the number of elements stored in the queue.
- Front: It is used to access the front elements of the queue in C++. It is an important queue function in C++ as it is responsible for deletion operations. Elements are deleted from the front.
- Back: It is used to access the rear element of the queue in C++. It is an important function as it is responsible for the insertion operations. Elements are added from the front.
- Push: It is used to insert a new element at the rear end of the queue in C++.
- Pop: It is used to delete a new element at the front end of the queue in C++.
- Emplace: It is used for the insertion of the new elements in the queue above the current rear element.
- Swap: It is used for interchanging the contents of two containers in the reference.
- Relational Operators: It is a non-member function that specifies the relational operators needed for the queues.
- Uses allocator \<queue\>: It is a non-member function that uses the allocator for the queues in C++.
### Example of Queue C++ Program Showing the Use of Various Functions:
\# include \<iostream\>
\# include \<queue\>
using namespace std;
void showsg (queue \<int\> sg)
{
queue \<int\> ss = sg;
while (!ss.empty())
{
cout \<\< ‘\\t’ \<\< ss.front();
ss.pop();
}
cout \<\< ‘\\n’;
}
int main()
{
Queue \<int\> fquiz;
fquiz.push(10);
fquiz.push(20);
fquiz.push(30);
cout \<\< “The queue fquiz is : “;
showsg(fquiz);
cout \<\< “\\nfquiz.size() : “ \<\< fquiz.size();
cout \<\< “\\nfquiz.front() : “ \<\< fquiz.front();
cout \<\< “\\nfquiz.back() : “ \<\< fquiz.back();
cout \<\< “\\nfquiz.pop() : “;
fquiz.pop();
showsg(fquiz);
return 0;
}
### Output:

Explain the member types of Queue C++, with their use cases
- container\_type: The underlying container type is specified using the container\_type member. It is the second template parameter.
- reference: It is a reference type of container member that is usually value\_type.
- const\_reference: It is a reference type of constant container that is usually const value\_type.
- value\_type: This member function specifies the types of the elements.
- size\_type: This member function specifies the types of the elements.
### Example of Queue C++ Program:
\# include \<iostream\>
\# include \<queue\>
using namespace std;
void showsg (queue \<int\> que)
{
queue \<int\> sq = que;
while (!sq.empty())
{
cout \<\< ‘\\t’ \<\< sq.front();
sq.pop();
}
cout \<\< ‘\\n’;
}
int main()
{
queue \<int\> fquiz;
fquiz.push(11);
fquiz.push(12);
fquiz.push(13);
cout \<\< “Here is the Queue : “;
showQueue(fquiz);
cout \<\< “\\nSize of Queue : “ \<\< fquiz.size();
cout \<\< “\\nFront of Queue: “ \<\< fquiz.front();
cout \<\< “\\nBack of Queue: “ \<\< fquiz.back();
return 0;
}
Want a Top Software Development Job? Start Here\!AI-Powered Full Stack Developer Program[Explore Program](https://www.simplilearn.com/full-stack-developer-course-mern-certification-training?source=GhPreviewCTABanner)

### Output:

## Wrapping Up
This article covers all the functions, member types, and examples of Queue in C++. Your search for the best learning about the queue in C++ ends at [Simplilearn](https://www.simplilearn.com/skillup-free-online-courses?referrer=top-nav#Software-Development "Simplilearn"). Along with basic free courses, it offers certified courses to become a [Post Graduate Program In Full Stack Web Development](https://www.simplilearn.com/certifications/full-stack-courses?source=GhPreviewCoursepages "Post Graduate Program In Full Stack Web Development") Learn from the best technical project managers that are seasoned in handling queues in C++.
SkillUp by Simplilearn is an initiative of the company to offer free courses in a variety of IT fields. Reach us to know more about it.
Have any questions regarding this article? Let us know in the comments section, and our experts will answer them for you, ASAP.
Happy learning\!
## Our Software Development Program Duration and Fees
Software Development programs typically range from a few weeks to several months, with fees varying based on program and institution.
| Program Name | Duration | Fees |
|---|---|---|
| [Full Stack Development Program with Generative AI](https://www.simplilearn.com/full-stack-web-development-ai-course?source=CohortTableCTA)Cohort Starts: **30 Apr, 2026** | 20 weeks | £2,400 |
| [AI-Powered Full Stack Developer Course](https://www.simplilearn.com/full-stack-developer-course-mern-certification-training?source=CohortTableCTA)Cohort Starts: **18 May, 2026** | 9 months | £519 |
| [Full Stack Java Developer Masters Program](https://www.simplilearn.com/java-full-stack-developer-certification?source=CohortTableCTA) | 7 Months | £1,500 |
| [AI-Powered Automation Test Engineer Program](https://www.simplilearn.com/automation-testing-masters-program-certification-training-course?source=CohortTableCTA) | 6 months | £1,099 |
## Recommended Reads
- [Digital Transformation and Future of Tech Jobs in India: A Simplilearn Report 202019 Jul, 2023](https://www.simplilearn.com/digital-transformation-and-future-of-tech-jobs-in-india-pdf)
- [Software DevelopmentIntroduction To Queue In Java177449 Jun, 2025](https://www.simplilearn.com/tutorials/java-tutorial/queue-in-java)
- [Software DevelopmentThe Ultimate Guide To Understand The Differences Between Stack And Queue1067485 Mar, 2026](https://www.simplilearn.com/tutorials/data-structure-tutorial/stacks-and-queues)
- [Skilling for the Digital Economy: A Role-Based Approach13 Apr, 2025](https://www.simplilearn.com/skilling-for-the-digital-economy-pdf)
- [Software DevelopmentA Holistic Look at Circular Queues in a Data Structure10108723 Jul, 2024](https://www.simplilearn.com/tutorials/data-structure-tutorial/circular-queue-in-data-structure)
- [Software DevelopmentA Comprehensive Look at Queue in Data Structure1344669 Sep, 2025](https://www.simplilearn.com/tutorials/data-structure-tutorial/queue-in-data-structure)
prevNext
Get Affiliated Certifications with Live Class programs

C++ Fundamentals
- 24x7 learner assistance and support
[View Program]()

AI-Powered Automation Test Engineer Program
- Learn through 130+ hours of core curriculum delivered in live online classes by industry experts
- Learn through 5 structured phases, including dedicated modules on Generative AI
6 months
[View Program]()
© 2009 -2026- Simplilearn Solutions.
Follow us\!
[Refer and Earn](https://www.simplilearn.com/refer-and-earn "Refer and Earn")
Company
[About us](https://www.simplilearn.com/about-us "About us")[Careers](https://www.simplilearn.com/careers "Careers") [Newsroom](https://www.simplilearn.com/partners/sl/newsroom "Newsroom") [Alumni speak](https://www.simplilearn.com/reviews "Alumni speak") [Grievance redressal](https://www.simplilearn.com/grievance-redressal "Grievance redressal")[Contact us](https://www.simplilearn.com/contact-us "Contact us")
Work with us
[Become an instructor](https://www.simplilearn.com/become-our-trainer "Become an instructor")[Blog as guest](https://www.simplilearn.com/guest-blogging "Blog as guest")
Discover
[Free Courses](https://www.simplilearn.com/skillup-free-online-courses "Free Courses")[Skillup Sitemap](https://www.simplilearn.com/skillup-sitemap "Skillup Sitemap")[Resources](https://www.simplilearn.com/resources "Resources")[RSS feed](https://www.simplilearn.com/feed "RSS feed")[SimpliMentor GPT](https://chatgpt.com/g/g-67a4945c34108191b5f4bef996e630a0-simplimentor "SimpliMentor GPT")
For Businesses
[Corporate training](https://www.simplilearn.com/corporate-training "Corporate training")[Simplilearn Learning Hub+](https://www.simplilearn.com/corporate-training/learning-hub-plus "Simplilearn Learning Hub+")[Guaranteed-to-run Classes](https://www.simplilearn.com/corporate-training/guaranteed-to-run-classes "Guaranteed-to-run Classes")[Corporate resources](https://www.simplilearn.com/resources/enterprise "corporate-resources")[Partners](https://www.simplilearn.com/corporate-training/reseller-partner-program-for-training-courses "Partners")
Learn On the Go\!
[Get the Android App](https://play.google.com/store/apps/details?id=com.mobile.simplilearn "Get the Android App")[Get the iOS App](https://apps.apple.com/app/simplilearn/id963042747?ls=1 "Get the iOS App")
Trending Post Graduate Programs
[Product Management Certification Course](https://www.simplilearn.com/product-management-certification-training-course "Product Management Certification Course") \| [Product Management Training Course](https://www.simplilearn.com/product-management-training-course-online "Product Management Training Course") \| [Cloud Computing and DevOps Course](https://www.simplilearn.com/ai-cloud-computing-and-devops-course "Cloud Computing and DevOps Course")
Trending Master Programs
[PMP Plus Certification Training Course](https://www.simplilearn.com/pmp-plus-bundle-masters-program "PMP Plus Certification Training Course") \| [Data Science Certifiation Course](https://www.simplilearn.com/data-science-course "Data Science Certifiation Course") \| [Data Analyst Course](https://www.simplilearn.com/uk/data-analyst-course "Data Analyst Course") \| [Cloud Architect Certification Training Course](https://www.simplilearn.com/cloud-solutions-architect-masters-program-training "Cloud Architect Certification Training Course") \| [DevOps Engineer Certification Training Course](https://www.simplilearn.com/devops-engineer-masters-program-certification-training "DevOps Engineer Certification Training Course") \| [Cyber Security Expert Course](https://www.simplilearn.com/cyber-security-expert-master-program-training-course "Cyber Security Expert Course") \| [Business Analyst Course](https://www.simplilearn.com/business-analyst-certification-training-course "Business Analyst Course") \| [AI-Powered Automation Testing Course](https://www.simplilearn.com/automation-testing-masters-program-certification-training-course "AI-Powered Automation Testing Course") \| [AWS Cloud Architect Course](https://www.simplilearn.com/aws-cloud-architect-certification-training-course "AWS Cloud Architect Course")
Trending Courses
[PMP Certification Training Course](https://www.simplilearn.com/project-management/pmp-certification-training "PMP Certification Training Course") \| [CSM Certification Course](https://www.simplilearn.com/agile-and-scrum/csm-certification-training "CSM Certification Course") \| [Data Science with Python Course](https://www.simplilearn.com/big-data-and-analytics/python-for-data-science-training "Data Science with Python Course") \| [AWS Certification](https://www.simplilearn.com/cloud-computing/aws-solution-architect-associate-training "AWS Certification") \| [CEH Certification](https://www.simplilearn.com/cyber-security/ceh-certification "CEH Certification") \| [AZ 900 Certification](https://www.simplilearn.com/microsoft-azure-fundamentals-az-900-certification "AZ 900 Certification") \| [CompTIA Security+ Certification](https://www.simplilearn.com/comptia-security-plus-certification-training "CompTIA Security+ Certification ") \| [AZ 400 Certification](https://www.simplilearn.com/microsoft-certified-devops-engineer-expert "AZ 400 Certification") \| [SAFe Certification](https://www.simplilearn.com/agile-and-scrum/safe-agilist-certification-training "SAFe Certification") \| [CISSP Certification Training](https://www.simplilearn.com/cyber-security/cissp-certification-training "CISSP Certification Training") \| [Tableau Certification Course](https://www.simplilearn.com/tableau-training-and-data-visualization-course "Tableau Certification Course") \| [Lean Six Sigma Green Belt Certification](https://www.simplilearn.com/quality-management/lean-six-sigma-green-belt-training "Lean Six Sigma Green Belt Certification") \| [Lean Six Sigma Black Belt Certification](https://www.simplilearn.com/quality-management/lean-six-sigma-black-belt-training "Lean Six Sigma Black Belt Certification") \| [Power BI Certification Course](https://www.simplilearn.com/power-bi-certification-training-course "Power BI Certification Course") \| [Java Certification Course](https://www.simplilearn.com/mobile-and-software-development/java-javaee-soa-development-training "Java Certification Course") \| [Python Certification Training Course](https://www.simplilearn.com/mobile-and-software-development/python-development-training "Python Certification Training Course")
Trending Categories
[Project Management Courses](https://www.simplilearn.com/courses/project-management "Project Management Courses") \| [Online Certifications](https://www.simplilearn.com/certifications "Online Certifications") \| [Generative AI Courses](https://www.simplilearn.com/courses/generative-ai "Generative AI Courses") \| [Agile Certifications](https://www.simplilearn.com/courses/agile-and-scrum "Agile Certifications") \| [Cloud Computing Courses](https://www.simplilearn.com/courses/cloud-computing "Cloud Computing Courses") \| [Cyber Security Courses](https://www.simplilearn.com/courses/cyber-security "Cyber Security Courses") \| [EC-Council Certifications](https://www.simplilearn.com/certifications/eccouncil-certifications "EC-Council Certifications") \| [PeopleCert Certifications](https://www.simplilearn.com/certifications/peoplecert-certifications "PeopleCert Certifications") \| [Scrum Alliance Certifications](https://www.simplilearn.com/certifications/scrum-alliance-certifications "Scrum Alliance Certifications") \| [Software Development Courses](https://www.simplilearn.com/courses/software-development "Software Development Courses") \| [Web Development Courses](https://www.simplilearn.com/courses/web-development "Web Development Courses") \| [Scaled Agile Certifications](https://www.simplilearn.com/certifications/scaled-agile-certifications "Scaled Agile Certifications") \| [ISC2 Certifications](https://www.simplilearn.com/certifications/isc2-certifications "ISC2 Certifications") \| [AXELOS Certifications](https://www.simplilearn.com/certifications/axelos-courses "AXELOS Certifications") \| [ISACA Certifications](https://www.simplilearn.com/certifications/isaca-certifications "ISACA Certifications") \| [PMI Certifications](https://www.simplilearn.com/certifications/pmi-certifications "PMI Certifications") \| [CompTIA certifications](https://www.simplilearn.com/certifications/comptia-certifications "CompTIA certifications") \| [AWS Courses](https://www.simplilearn.com/courses/aws "AWS Courses") \| [Microsoft Certifications](https://www.simplilearn.com/certifications/microsoft-certification "Microsoft Certifications") \| [AI Courses](https://www.simplilearn.com/courses/ai "AI Courses") \| [Digital Marketing Courses](https://www.simplilearn.com/courses/digital-marketing "Digital Marketing Courses")
Trending Resources
[Python Tutorial](https://www.simplilearn.com/tutorials/python-tutorial "Python Tutorial") \| [JavaScript Tutorial](https://www.simplilearn.com/tutorials/javascript-tutorial "JavaScript Tutorial") \| [Java Tutorial](https://www.simplilearn.com/tutorials/java-tutorial "Java Tutorial") \| [Angular Tutorial](https://www.simplilearn.com/tutorials/angular-tutorial "Angular Tutorial") \| [Node.js Tutorial](https://www.simplilearn.com/tutorials/nodejs-tutorial "Node.js Tutorial") \| [Docker Tutorial](https://www.simplilearn.com/tutorials/docker-tutorial "Docker Tutorial") \| [Git Tutorial](https://www.simplilearn.com/tutorials/git-tutorial "Git Tutorial") \| [Kubernetes Tutorial](https://www.simplilearn.com/tutorials/kubernetes-tutorial "Kubernetes Tutorial") \| [Power BI Tutorial](https://www.simplilearn.com/tutorials/power-bi-tutorial "Power BI Tutorial") \| [CSS Tutorial](https://www.simplilearn.com/tutorials/css-tutorial "CSS Tutorial")
OK
- [Terms and Conditions](https://www.simplilearn.com/terms-and-conditions#terms-and-conditions "Terms and Conditions")
- [Privacy Policy](https://www.simplilearn.com/terms-and-conditions#privacy-policy "Privacy Policy")
- [Refund Policy](https://www.simplilearn.com/terms-and-conditions#refund-policy "Refund Policy")
- © 2009-2026 - Simplilearn Solutions. All Rights Reserved. The certification names are the trademarks of their respective owners.
smpl\_2026-04-16
- Acknowledgement
- PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, OPM3 and the PMI ATP seal are the registered marks of the Project Management Institute, Inc.
- \*All trademarks are the property of their respective owners and their inclusion does not imply endorsement or affiliation.
- Career Impact Results vary based on experience and numerous factors. |
| Readable Markdown | C++ is an extension to [C programming](https://www.simplilearn.com/c-programming-article "C programming") and is an object-oriented programming language. It, however, has certain features like Friend and Virtual that violate some of the object-oriented programming language features.
C++ is a more robust language than C as it has strong type checking and has features like Encapsulation, Inheritance, and Abstraction. The other features like [Exception Handling](https://www.simplilearn.com/tutorials/cpp-tutorial/exception-handling-in-cpp "Exception Handling"), Operator Overloading, and Function Overloading make it a priority language for developers.
## What Is a Queue in C++? Explain With Syntax and an Example
The queue in C++ is a large data structure. Queue in C++ uses an encapsulated object of the sequential container class as its principal container. It provides a particular set of member functions that can access its elements.
### Syntax of C++ queue
Template\<class T, class Container = deque\<T\> \> class queue;
The insertion of queues in C++ takes place at the rear end, and the deletion takes the front. The rear end or rear element is the last element in the queue. The front or the front element is the element at the first position in the queue.
Queue in C++ works in the “first in first out” technique. It means that the element that you insert first is extracted first, and so on. The queues are indicated as the container adaptors in the application areas.
Every container has support for the main operations list that includes size, pop\_front, back, front, push\_back, and empty. The different template parameters are:
- Container: This argument defines the internal object of the container where all the queue elements are stored.
- T: This argument defines the type of element that will be held by the container adaptor.
### All Queues must allow:
- Enqueue: The addition of an element at the end of the queue.
- Dequeue: The removal of an element from the front of the queue.
- IsEmpty: The checking of the queue if it is empty.
- IsFull: The checking of the queue if it is full.
- Peek: Obtaining the value of the front of the queue without removing the element.
### Advantages of Queue C++:
- It is used in applications in which data is transferred asynchronously between two processes. The queue in C++ can be used for obtaining the synchronization.
- The call center systems use queues to hold the incoming calls and to resolve them one by one.
- The queues can handle the interrupts in a real-time system and are ideal for disk scheduling and CPU scheduling.
## Explain the Various Functions of C++ Queue, With Their Use Cases
The different functions of the queue in C++ are:
- Constructor: It is used for the construction of a queue container.
- Empty: It is used to test the emptiness of a queue in C++. This function returns true if the queue is empty and returns false if the queue is not empty.
- Size: It returns the size of the queue container that is the measure of the number of elements stored in the queue.
- Front: It is used to access the front elements of the queue in C++. It is an important queue function in C++ as it is responsible for deletion operations. Elements are deleted from the front.
- Back: It is used to access the rear element of the queue in C++. It is an important function as it is responsible for the insertion operations. Elements are added from the front.
- Push: It is used to insert a new element at the rear end of the queue in C++.
- Pop: It is used to delete a new element at the front end of the queue in C++.
- Emplace: It is used for the insertion of the new elements in the queue above the current rear element.
- Swap: It is used for interchanging the contents of two containers in the reference.
- Relational Operators: It is a non-member function that specifies the relational operators needed for the queues.
- Uses allocator \<queue\>: It is a non-member function that uses the allocator for the queues in C++.
### Example of Queue C++ Program Showing the Use of Various Functions:
\# include \<iostream\>
\# include \<queue\>
using namespace std;
void showsg (queue \<int\> sg)
{
queue \<int\> ss = sg;
while (!ss.empty())
{
cout \<\< ‘\\t’ \<\< ss.front();
ss.pop();
}
cout \<\< ‘\\n’;
}
int main()
{
Queue \<int\> fquiz;
fquiz.push(10);
fquiz.push(20);
fquiz.push(30);
cout \<\< “The queue fquiz is : “;
showsg(fquiz);
cout \<\< “\\nfquiz.size() : “ \<\< fquiz.size();
cout \<\< “\\nfquiz.front() : “ \<\< fquiz.front();
cout \<\< “\\nfquiz.back() : “ \<\< fquiz.back();
cout \<\< “\\nfquiz.pop() : “;
fquiz.pop();
showsg(fquiz);
return 0;
}
### Output:

Explain the member types of Queue C++, with their use cases
- container\_type: The underlying container type is specified using the container\_type member. It is the second template parameter.
- reference: It is a reference type of container member that is usually value\_type.
- const\_reference: It is a reference type of constant container that is usually const value\_type.
- value\_type: This member function specifies the types of the elements.
- size\_type: This member function specifies the types of the elements.
### Example of Queue C++ Program:
\# include \<iostream\>
\# include \<queue\>
using namespace std;
void showsg (queue \<int\> que)
{
queue \<int\> sq = que;
while (!sq.empty())
{
cout \<\< ‘\\t’ \<\< sq.front();
sq.pop();
}
cout \<\< ‘\\n’;
}
int main()
{
queue \<int\> fquiz;
fquiz.push(11);
fquiz.push(12);
fquiz.push(13);
cout \<\< “Here is the Queue : “;
showQueue(fquiz);
cout \<\< “\\nSize of Queue : “ \<\< fquiz.size();
cout \<\< “\\nFront of Queue: “ \<\< fquiz.front();
cout \<\< “\\nBack of Queue: “ \<\< fquiz.back();
return 0;
}
### Output:

## Wrapping Up
This article covers all the functions, member types, and examples of Queue in C++. Your search for the best learning about the queue in C++ ends at [Simplilearn](https://www.simplilearn.com/skillup-free-online-courses?referrer=top-nav#Software-Development "Simplilearn"). Along with basic free courses, it offers certified courses to become a [Post Graduate Program In Full Stack Web Development](https://www.simplilearn.com/certifications/full-stack-courses?source=GhPreviewCoursepages "Post Graduate Program In Full Stack Web Development") Learn from the best technical project managers that are seasoned in handling queues in C++.
SkillUp by Simplilearn is an initiative of the company to offer free courses in a variety of IT fields. Reach us to know more about it.
Have any questions regarding this article? Let us know in the comments section, and our experts will answer them for you, ASAP.
Happy learning\! |
| Shard | 79 (laksa) |
| Root Hash | 17406570482395038879 |
| Unparsed URL | com,simplilearn!www,/tutorials/cpp-tutorial/queue-in-cpp s443 |