Define precondition and post-condition to a member function?



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

Post New Answer

More C++ General Interview Questions

Problem 5: Hero's Formula is A method for calculating the area of a triangle when you know the lengths of all three sides. Let a, b, c be the lengths of the sides of a triangle. The area is given by:A= pp-ap-b(p-c) | wherep= a+b+c2 | | Write a C-language code to calculate area of triangle using above method. Take the three lengths of the triangle from the user and display the area that your program calculates.

0 Answers   Maxobiz,


When is the destructor called?

0 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create

0 Answers  


When the design recommends static functions?

2 Answers   Symphony,


Explain virtual class and friend class.

0 Answers  






Give example of a pure virtual function in c++?

0 Answers  


Given a simple program designed to take inputs of integers from 1-1000 and to output the factorial value of that number, how would you test this program? You do not have access to the code. Please be as specific as possible.

4 Answers   Microsoft,


What is a pointer how and when is it used?

0 Answers  


Write my own zero-argument manipulator that should work same as hex?

0 Answers  


What are inline functions?

2 Answers   Fidelity, Verizon,


How can you quickly find the number of elements stored in a a) static array b) dynamic array ?

5 Answers   Lucent,


What does I ++ mean in c++?

0 Answers  


Categories