Thread: Implementing of queue using objects?

  1. #1
    Argo Argo_Jeude's Avatar
    Join Date
    Jul 2005
    Location
    Bihać, Bosnia
    Posts
    21

    Implementing of queue using objects?

    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!?
    Please don't throw rocks at me !

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    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.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Argo Argo_Jeude's Avatar
    Join Date
    Jul 2005
    Location
    Bihać, Bosnia
    Posts
    21
    Yeah, that makes sense.
    ThanX!
    Please don't throw rocks at me !

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Argo_Jeude View Post
    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!?
    std::deque ???

  5. #5
    Argo Argo_Jeude's Avatar
    Join Date
    Jul 2005
    Location
    Bihać, Bosnia
    Posts
    21
    Quote Originally Posted by brewbuck View Post
    std::deque ???
    I don't understand...
    std::deque ?
    Please don't throw rocks at me !

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  4. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 11:39 AM
  5. queue help
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-29-2001, 09:38 AM