Queues... what the hell are they?
Queues are probably the most basic STL container. They don't really have too many commands, and they aren't very flexible. You can probably guess where they get their name from... think of a queue in a shop, they do about the same thing.

Starting our program
First off, we need to include the right stuff. All we need to include is #include <queue> and be using std::queue; but I'm gonna be using #include <iostream> just so that you can see what's happening.

Creating a queue and adding values
Very simple to create, pretty much the same as any other STL creation. Also note that we use push() to add something to the queue... this does pretty much the same thing as push_back() would in a vector:

Simple, huh? Damn straight it is, and it doesn't get much harder, either.

Accessing the stuff in a queue
Really simple yet again, all we do in this next bit is make calls to 3 function, all of which are self explanatory:

size() returns the size of the queue (how many members are in it)

front() accesses the front element of the queue (the first one added)

back() accesses the back element of the queue (the last one added)

Notice the similarities to a queue in a shop? Basically, queue follows a "first come, first serve" pattern.

cout << "There are currently " << names.size () << " people in the queue" << endl
<< "The person at the front of the queue is " << names.front () << endl
<< "The person at the back of the queue is " << names.back () << endl << endl;

Removing an element from a queue
Now, remember how I said it follows a "first come, first serve" rule? This is where you see it in action. The front member in the queue (currently me, Danny) is going to be first out of the queue, right? This is simple enough too:

what if my name consist of 2 words
how can i input it in the queue including the whitespaces
because when im trying to use cin>>name or getline(cin,name) it gives me an error
not a compiler error but rather a logical error i think

I'm parsing a financial data feed, and I have a thread that is invoked when an item arrives in the feed. I'm slightly worried that if I parse the item directly in this thread and place the values in global structures, the thread may not be available to receive the next item in the feed, since the thread is busy parsing. So, I'm thinking about having the invoked thread simply push the market data (string) into a queue. I will have a second thread parse items off the top of the queue. My question is, is this overkill? Should I just parse in the invoked thread and assume these new machines are so fast they won't miss anything?