MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / main

Function main

Examples/Modules/Chapter 20/Ex20_02/Ex20_02.cpp:6–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import <queue>;
5
6int main()
7{
8 std::stack<int> stack;
9 for (int i {}; i < 10; ++i)
10 stack.push(i);
11
12 std::cout << "The elements coming off the top of the stack: ";
13 while (!stack.empty())
14 {
15 std::cout << stack.top() << ' ';
16 stack.pop(); // pop() is a void function!
17 }
18 std::cout << std::endl;
19
20 std::queue<int> queue;
21 for (int i {}; i < 10; ++i)
22 queue.push(i);
23
24 std::cout << "The elements coming from the front of the queue: ";
25 while (!queue.empty())
26 {
27 std::cout << queue.front() << ' ';
28 queue.pop(); // pop() is a void function!
29 }
30 std::cout << std::endl;
31}

Callers

nothing calls this directly

Calls 3

pushMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected