queue getter function

alright so basically i'm doing an assignment where i have to have people enter their name and it puts it in a queue. i also have to be able to display the queue at anytime and thats where i'm stuck. id like to be able to send all of the queue info automatically to a different fine and at anytime i can press 'A' (as in the code that follows) and it will show the queue info. anyhelp would be great! here's my code so far. basic C++ syntax and i'm using codeblocks:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <list>
#include <queue>
#include <string>
using namespace std;

int main()
    {
        queue<string> myqueue;
        string strName;
        char cContinue;
        char cAccess;

        while(1)
            {
                cout << "Hello! Welcome to C++ Bank of America! \n" << endl;
                cout << "If you do not wish to wait in line, enter '0' and leave the bank. \n" << endl;
                cout << "If you wish to continue, press any key" << endl;


                cin >> cContinue;

                    if(cContinue != '0')
                        {
                            cout << "Please enter your Name" << endl;
                            cin >> strName;
                            myqueue.push (strName);
                            cout << "Thank you for choosing C++ Bank of America!" << endl;
                            cout << "To Accsess the queue, please enter 'A'. Otherwise, please press any key." << endl;
                            if(cAccess != 'A')
                        }




            }



        return 0;
    }
Last edited on
Please edit your post and put the source inside code tags. It will make it a lot more legible and folks here will be more likely to pay attention to it.
howwww do i do that?
ahh fixed it
Have you studied functions and references yet?
all i really need is just a few popinters to put me in the right direction. i don't really need any code.
closest iv'e come to studying that is getter and setter functions. i also realized i probably need to make some classes
Very reasonable problem. Looked around a bit and found this:
http://stackoverflow.com/questions/1185252/is-there-a-way-to-access-the-underlying-container-of-stl-container-adaptors

The solution unfortunately appears to be not so reasonable. The above link will lead you to demonstration on how to gain access to the protected member of the adaptor classes. This should be standard compliant (unless stuff in the standard gets "cleaned").

There are other legitimate reasons to do something like this.
http://www.cplusplus.com/forum/general/22354/

This post mentions compacting the underlying vector when dealing with stack and priority queue. The advice is not to do it, but I just wanted to say that the likes of your problem (accessing the underlying container of the adaptors) comes up apparently.

Regards

EDIT: Thought about it again. The above solution is very esoteric and probably you will need simpler alternative. You can use the deque container. Queues are not very thick layer above deque, so the transition will be simple.
Last edited on
Just destroy the container.
Read the top, remove it from the queue, [put it in again]
Last edited on
Topic archived. No new replies allowed.