Define precondition and post-condition to a member function?
Answer Posted / akhilesh kumar jaiswal
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.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are function prototypes?
What is vector string in c++?
Write a program using display() function which takes two arguments.
What is the difference between an array and a list?
List the issue that the auto_ptr object handles?
What is private public protected in c++?
Can you sort a set c++?
What is the use of :: operator in c++?
What is the use of endl?
Const char *p , char const *p What is the difference between the above two?
Why is c++ still used?
Explain "const" reference arguments in function?
What is stack unwinding?
Does c++ cost money?
Does c++ have string data type?