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 is the real purpose of class – to export data?
Write a code/algo to find the frequency of each element in an array?
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,
What are the differences between a struct and a class in C++?
What does ios :: app do in c++?
Tell me can a pure virtual function have an implementation?
What is meant by entry controlled loop?
0 Answers Agilent, ZS Associates,
What is a .h file c++?
What is pointer in c++ with example?
What is abstract keyword in c++?
Implement strcmp
What is the benefit of encapsulation?