c++ - Push object into queue -
i have class below.
how write class want write fields in private, after how push them queue , read them out of queue?
thanks!
class pcb { 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; };
to edit values:
pcb mypcb; mypcb.setpid(3); mypcb.setfilename("myfile.pcb"); to push values onto stack:
std::stack<pcb> mystack; mystack.push(mypcb); to view , pop pcbs:
pcb toppcb = mystack.top(); mystack.pop();
Comments
Post a Comment