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

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -