How to Dequeue an Element from a Queue in C++? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In C++, queues are a type of container adaptors that operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front. In this article, we will learn how to dequeue an element from a queue in C++ STL. Example: Input: Create a queue and enqueue the values {1, 2, 3, 4, 5}.Output: Queue after dequeue: {2, 3, 4, 5}, after dequeue the first element.Dequeuing an Element from a Queue in C++To dequeue an element from a queue in C++, we can use the std::queue::pop() function. This function deletes or dequeues the first element of the queue. C++ Program to Dequeue an Element from a Queue C++ // C++ Program to illustrate how to dequeue an element from // a queue #include <iostream> #include <queue> using namespace std; // Driver Code int main() { // Creating a queue of integers queue<int> q; // Enqueueing elements into the queue for (int i = 1; i <= 5; ++i) { q.push(i); } // Dequeueing an element from the queue q.pop(); // Displaying the queue elements while (!q.empty()) { cout << q.front() << " "; q.pop(); } cout << endl; return 0; } Output2 3 4 5 Time Complexity: O(1) Space Complexity: O(1) Create Quiz Comment R rohitpant4532 Follow 0 Improve R rohitpant4532 Follow 0 Improve Article Tags : C++ Programs C++ STL cpp-deque CPP Examples +1 More Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like