I have a class below

class CPU
        void setPID (int a)
            PID = a;
        int retrievePID()
            return PID;
        int PID;

And i am curious if you can create a queue into this class?

I am trying to queue in a value into the PID

I setup my queue below.

        queue<CPU> CPUQueue;

But im not sure how to queue into the value PID?

How does this work i am very confused.

3 Years
Discussion Span
Last Post by David W

A queue ... is just a first in ... first out (FIFO) data structure ...

What are you trying to do with a queue ... C++ has one in the STL that you can test out, and use.

Click Here

Edited by David W: added link


Isnt there a way to add in a queue to stuff in the class? Like if i was to add sex age location to a class and put that in a queue?


You seem to have this 'backwards' :)

You load (assign) data into (each member in) a data struct

Then you add (push) each loaded (data) struct to the queue.

Code your stuct

struct Contact
    string name;
    int id;

    Contact( string n="", int i=0 ) : name(n), id(i) {}
} ;

queue < Contact > myQ; // construct empty queue
Contact tmp( "David", 717 );
myQ.push( tmp );
// etc ...

Edited by David W: added code

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.