Hello guys, I am looking for some help and some reassurance if I am on the right track. I am most likely not, which is what I think. First thing I would like for you guys to check my code if I wrote everything correctly inside the functions. Second, I really don't know what to write inside the Function "Front()". Which is where I am stuck on so far.
Everything I have so far inside the functions is what I got and understood from the book I was assigned. I notice in online examples there is a pointer happening inside dequeue and enqueue. I couldn't really build off the online examples since many of them use a variable called next and their enqueue and dequeue are boolean functions. So I need specific advice.
Thanks for the reply! . So far I have fixed most of thing you have mentioned. Except in line 43, I'm not sure how I will be doing all of it correctly.
Only method I could think of right now is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void CQueue::Dequeue(Passenger& newitem) //making it a parameter and passing it by reference
{
if (IsEmpty)
{
cout << "Queue is Empty" << endl;
}
else
{
front = (front + 1) % MAX;
newitem = passengers[front];
}
}
Sadly, the professor doesn't like when we change the code. When I also just state
Passenger& newitem;
inside the function, I get an error saying. newitem requires an initializer.
Still in need of some help. I still can't find a solution to my Dequeue function. Also my enqueue function is also not working when I run the entire program.