Well, he didn't said that he want to use stack either.
OP should tell exactly what does he want to use.
I assumed that he wants to use std::queue to store information and print it. And in standard queue (and stack BTW) pop() method returns void, so we should use front() method to read value before popping it out.
std::cout << foo.front() << " ";//This is the output (we are outputting value on top)
foo.pop();//Delete value on top
In second program there is, in fact, output too. But it is better not to use that approach ever.