c++ - Classes and Queue's -
i trying figure out how work queues , classes.
how can insert information class queue?
i created queue queue<processes> printerdevices
how go insert stuff on queue class or reading it?
class processes { public: void setpid (int a) { pid = a; } int retrievepid() { return pid; } void setfilename (string input) { filename = input; } string retrievefilename() { return filename; } void setmemstart (int a) { memstart = a; } int retrievememstart() { return memstart; } void setrw (char a) { rw = a; } int retrieverw() { return rw; } void setfilelength (string input) { filelength = input; } string retrievefilelength() { return filelength; } private: int pid; string filename; int memstart; char rw; string filelength; };
queue<processes> printerdevices; processess obj; //populate object through setter methods
to add object queue printerdevices
`printerdevices.push(obj);`
similarly can create more object.. traverse...
while(!printerdevices.empty()) { processes obj = printerdevices.front(); //add code use obj; printerdevices.pop();//remove object queue used above }
Comments
Post a Comment