int move_to_rear(int Item)
{
linkedQueueType<int> myQueue;
const Item first = myQueue.front(); //getting the first
myQueue.deleteQueue(); //moving him to the back;
myQueue.addQueue(first); //adding him back to the queue(which will be in the rear)
Here is the program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include<iostream>
#include "linkedQueue.h"
#include<queue>
usingnamespace std;
int move_to_rear(int Item);
int main()
{
int Item;
linkedQueueType<int> myQueue;
myQueue.addQueue(1732);
myQueue.addQueue(1767);
myQueue.addQueue(1734);
myQueue.addQueue(1764);
myQueue.addQueue(1766);
move_to_rear(1732);
After the execution of this program, 1732 sould be the last element
I get there two errors:
1 2 3 4 5 6 7 8 9
C:\Martin\MalikChapter8\Chapter 8 Source Code\linkedQueue\queueTest.cpp:30:8: error: 'Item' does not name a type
^
C:\Martin\MalikChapter8\Chapter 8 Source Code\linkedQueue\queueTest.cpp:32:18: error: 'first' was not declared in this scope
myQueue.addQueue(first); //adding him to the back to the queue(which will be the rear
^
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
int move_to_rear(int Item)
{
linkedQueueType<int> myQueue;
const Item first = myQueue.front(); //getting the first
myQueue.deleteQueue(); //moving him to the back;
myQueue.addQueue(first); //adding him back to the queue(which will be in the rear)
///
move_to_rear(1732);
Why isn't move_to_rear a member function?
Why do you create a completely new temporary myQueue inside the function?
> Why isn't move_to_rear a member function?
¿why should it? it can be implemented fine as a non-friend free function.
int move_to_rear(int Item)
¿what's the purpose of that parameter?
¿and what do you return?
> error: 'Item' does not name a type
just a couple of lines above you said that `Item' was a variable, not a type
also, ¿is your function supposed to be a template?
myQueue.deleteQueue(); //moving him to the back;
that comment doesn't correspond with that line