Define precondition and post-condition to a member function.
Page 1 of 1
Define precondition and post-condition to a member function.
Answer:
Precondition:
A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold.
For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation.
Post-condition:
A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false.
For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.
Database interview questions
Click here More information available
Precondition:
A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold.
For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation.
Post-condition:
A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false.
For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.
Database interview questions
Click here More information available
Similar topics
» Define namespace.
» In an AVL tree, at what condition the balancing is to be done?
» What are the conditions that have to be met for a condition to be an invariant of the class?
» In an AVL tree, at what condition the balancing is to be done?
» What are the conditions that have to be met for a condition to be an invariant of the class?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|