Programming Precept After a client uses a class method it should decide whether to check the resulting error status. Classes should be designed to allow clients to decide how to respond to errors C++ also provides more sophisticated error processing called exception handling. The standard library implementations of classes use exception handling but we shall opt for the simplicity of returning error codes in all our implementations
Programming Precept After a client uses a class method, it should decide whether to check the resulting error status. Classes should be designed to allow clients to decide how to respond to errors. C++ also provides more sophisticated error processing called exception handling. The standard library implementations of classes use exception handling, but we shall opt for the simplicity of returning error codes in all our implementations
1. Specification of Method for Stack Error_code Stack pop; Pre: None Post: If the Stack is not empty the top of the Stack is removed. If the stack is empty, an Error code of underflow is returned and the stack is left unchanged
Error_code Stack :: pop( ); Pre: None. Post: If the Stack is not empty, the top of the Stack is removed. If the Stack is empty, an Error code of underflow is returned and the Stack is left unchanged. 1. Specification of Method for Stack
Error code Stack push(const Stack entry &item)i Pre: none Post: If the Stack is not full, item is added to the top of the stack. If the stack is full. an Error code of overflow is returned and the stack is left unchanged Error_code Stack top(Stack entry &item)const; Pre: none Post: The top of a nonempty Stack is copied to item a code of fail is returned if the stack is empty
Error_code Stack :: top(Stack entry &item) const; Pre: None. Post: The top of a nonempty Stack is copied to item. A code of fail is returned if the Stack is empty. Error_code Stack :: push(const Stack entry &item); Pre: None. Post: If the Stack is not full, item is added to the top of the Stack. If the Stack is full, an Error code of overflow is returned and the Stack is left unchanged
Error code Stack empty()const Pre: None Post: a result of true is returned if the stack is empty, otherwise false is returned. Error_ code Stack top(Stack entry &item)const Pre: None Post: The top of a nonempty Stack is copied to item A code of fail is returned if the Stack is empty
Error_code Stack :: top(Stack entry &item) const; Pre: None. Post: The top of a nonempty Stack is copied to item. A code of fail is returned if the Stack is empty. Error_code Stack :: empty( ) const; Pre: None. Post: A result of true is returned if the Stack is empty, otherwise false is returned