Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to use C++ template to implement a Queue class using C++ vectors so that your queue class can store data of any type.

You need to use C++ template to implement a Queue class using C++ vectors so that your queue class can store data of any type. Since you use C++ vectors, you will not need to specify queue sizes. Your class should provide at least the following functions:

(1) top(), which returns the top of the queue;

(2) pop(), which returns the top of the queue and also remove it from the queue;

(3) push(), which inserts an element into the end of the queue;

(4) empty(), which returns whether the queue is empty.

Your main function needs to do the following:

(1) Instantiate a queue of integers; push integers 1, 2, 3, 4, 5, and 6 into the queue one by one, then pop all of them out and print out each number that you pop (which will be in the order of 1, 2, 3, 4, 5, and 6.

(2) Instantiate a queue of doubles; push doubles 0.1, 0.2, 0.3, 0.4, 0.5, and 0.6 into the queue one by one, then pop all of them out and print out each number that you pop (which will be in the order of 0.1, 0.2, 0.3, 0.4, 0.5, and 0.6.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

Students also viewed these Databases questions

Question

a score of 70 or higher on the test?

Answered: 1 week ago