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

Where the memory to the static variables is allocated?

0 Answers  


Can c++ be faster than c?

0 Answers  


write a program that a 5 digit number and calculates 2 power that number and prints it.

2 Answers   Vimukti Technologies,


Why #include is used?

0 Answers  


What is slicing?

1 Answers  


Which is the best c++ compiler?

0 Answers  


write a function signature with various number of parameters.

0 Answers  


What are the debugging methods you use when came across a problem?

1 Answers  


Differentiate between declaration and definition.

0 Answers  


Can we get the value of ios format flags?

0 Answers  


How Virtual functions call up is maintained?

2 Answers  


What is ios :: in in c++?

0 Answers  


Categories