辅导Templates留学生、辅导C++程序语言、讲解C++、辅导vectors
- 首页 >> C/C++编程Homework 7
The goal of this homework is get you familiar with C++ Templates.
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.
Due: February 5
th, 11:59PM, 2019.
Turn in one file via handin: the zip file of your whole NetBean directory. The name of your file
should be: LastName_FirstName.zip. For example, if your name is John Smith, you should
turn in one files: Smith_John.zip.