Define precondition and post-condition to a member function?
Answer / 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 |
What jobs can you get with a c++ certification?
What is the difference between a definition and a declaration?
What is the maximum value of a unsigned char a) 255 b) 256 c) 128
What is a sequence in c++?
How do we balance an AVL Tree in C++?
How can you say that a template is better than a base class?
Write a String class which has: 1) default constructor 2) copy constructor 3) destructor 4) equality operator similar to strcmp 5) constructor which takes a character array parameter 6) stream << operator
2 Answers HCL, Lehman Brothers, Zoomerang,
How many types of comments are there in c++?
What is namespace std; and what is consists of?
Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
Is it possible to have a recursive inline function in c++?
In what situations do you have to use initialization list rather than assignment in constructors?