#include <iostream>
#include <queue>
using namespace std;
template<class T, class C>
void ShowQueue(const queue<T, C>& aQueue);
int main()
{
// create a integer queue
queue<int> qInt;
cout << "Queue qInt created:\n";
ShowQueue(qInt);
// push elements into the queue
for (unsigned int i = 1; i < 5; ++i)
qInt.push(i * 2);
cout << "qInt:\n";
ShowQueue(qInt);
// modify the first and last elements
qInt.front() = 20;
qInt.back() = 30;
cout << "The first and last elements modified:\n";
ShowQueue(qInt);
// remove first element from the queue
qInt.pop();
cout << "After one pop() operation\n";
ShowQueue(qInt);
return 0;
}
//
// Display queue elements
//
template<class T, class C>
void ShowQueue(const queue<T, C>& aQueue)
{
cout << "size() = " << aQueue.size();
if (!aQueue.empty())
{
cout << "\tfront() = " << aQueue.front();
cout << "\tback() = " << aQueue.back();
}
cout << "\n\n";
}