Labs ICT
🎓 SIWES/IT Login

Queue

1 min read | C++ Tutorial
🎓

Doing SIWES / IT attachment?

Get a structured training programme, a supervised digital logbook, and a completion certificate with LabsICT SIWES / IT.

Explore SIWES / IT Training

C++ Queue

std::queue follows the FIFO (First In, First Out) principle. Elements are added at the back with push() and removed from the front with pop(). Access the front element with front() and the back with back(). Queues model real-world lines and are used in BFS and task scheduling.

#include <iostream>
#include <queue>

int main() {
    std::queue<std::string> q;
    q.push("first");
    q.push("second");
    q.push("third");
    std::cout << "Front: " << q.front() << "\n";
    q.pop();
    std::cout << "Front after pop: " << q.front();
    return 0;
}