c++ - using bool to quit from commanline -


i have following requirement 1 of program using quit():-

quit

(1) when quit command received, mainpart() function of statdata should return main()
(2) in addition, if eof reached, regardless of whether there quit command, mainpart() should return
(3) in turn, main() main return , program terminate
(4) not call exit()

so program looks :-

main() should this...

#define bool done;  int main()  {     statdata statdata;     statdata.mainpart();     return 0; } 

and mainpart() looks like...

void statdata::mainpart()   {      while (!cin.eof() && !done)          processcommand();            }   void rbapp::processcommand() {  string command;  cin>>command;    if(command == "quit")  {  processquit();  }   bool statdata::processquit() {  if(command=='quit') {  done=true;  return main(); } else {  done=false;  return done; } } 

i don't know going wrong. logic not working per specifications given. cannot use exit() in logic. please me. in advance.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -