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.

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

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 ...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.