I have to make a code about "Implementing of queue using objects" but I don't know what exactly do I do.
Now, I don't ask a code, just explanation.
Please help!?
Printable View
I have to make a code about "Implementing of queue using objects" but I don't know what exactly do I do.
Now, I don't ask a code, just explanation.
Please help!?
Using classes may-be?
A queue should be a FIFO type of container. It must provide means to push elements at one end of the container, and access (and remove) elements on the other end. Besides that you might need a member function to report if the queue is empty.
Using classes you'd hide the implementation details of the container itself (probably managing dynamically allocated raw memory, unless you are allowed to use STL - in which case you might just make a wrapper around std::queue) using the private keyword and only expose the interface consisting of methods such as Pop(Front), Push(Back), Front and IsEmpty.
Yeah, that makes sense.
ThanX!
It is a container in the standard library that would be useful in implementing a queue.
In fact, there is already a queue in the standard library, so if this was not a learning exercise, you would want to just use that (#include <queue>).
If you cannot use the standard library, then you would probably want to use a linked list or array as your internal container.