DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
An Objection Class for Rudimentary Error Handling - Objection(C++)

Sustaining an Objection

Objections need not be addressed in the user program at all if the client programmer is satisfied with the default actions that take place on the stack underflow and overflow errors. For example, consider the following routine which reads integers from standard input and prints them in reverse order:

      #include <Stack.h>
      #include <iostream.h>
      Stack st;
      int pnum=0;
      void silly_routine()
      {
          int i;
          while( ( cin >> i ) {
              st.push(i);
              pnum++;
          }
          while(pnum > 0) {
              cout << st.pop() << "\ n";
              pnum--;
          }
      }

When the 11th integer is read in and push()'ed onto the stack, the Stack::overflow Objection will be raised and the program will abort.


Next topic: Ignoring an Objection
Previous topic: Objections for the Software Client

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005