Skip to content
Justice Tech School

stack and queue

stack is last in first out and queue is first in first out.

Example
#include <iostream>
#include <stack>
#include <queue>

int main() {
  std::stack<int> s; s.push(1); s.push(2);
  std::queue<int> q; q.push(1); q.push(2);
  std::cout << s.top() << " " << q.front() << "\n";
  return 0;
}

Result

2 1

Exercise

LIFO container.

std::<int>

Quiz Test

Queue order is?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.