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
Is there finally in c++?
How are virtual functions implemented in c++?
Is atoi safe?
What is the fastest c++ compiler?
What is a down cast?
How can an improvement in the quality of software be done by try/catch/throw?
Which bit wise operator is suitable for turning off a particular bit in a number?
What do you mean by const correctness?
Is c++ a software?
What does override mean in c++?
How do you differentiate between overloading the prefix and postfix increments?
what are function pointers?
How to declare an array of pointers to integer?
What are c++ storage classes?
What is the two main roles of operating system?