← Back to STL Containers
Question 487
Build a Queue from a Vector
Build a Queue from a Vector
Write a functionqueue<int> toQueue(const vector<int>& v)that returns a newqueue<int>containing the elements ofvin the same order, sov[0]ends up at the front of the queue. The first test builds a queue from {4, 8, 15}, drains it and prints the values separated by spaces (see Expected Output). The second test passes an empty vector and prints the size of the returned queue: Size: 0 Do NOT write a main function.
Expected Output:
4 8 15 Size: 0
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
STL ContainersQueues
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.