What is class invariant?



What is class invariant?..

Answer / subham chaudhary

A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is else syntax in c++?

0 Answers  


What is meant by entry controlled loop? What all C++ loops are exit controlled?

0 Answers   TCS,


What is the difference between Pointer and a Reference? When you would use them?

4 Answers   Wipro,


Explain the scope of resolution operator.

0 Answers  


How do you decide which integer type to use?

0 Answers  






What is the importance of mutable keyword?

0 Answers  


Write a program to find the Fibonacci series recursively.

0 Answers   Huawei,


How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?

0 Answers  


How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?

0 Answers   Yahoo,


Why do we need runtime polymorphism in c++?

0 Answers  


What language does google use?

0 Answers  


Write a code/algo to find the frequency of each element in an array?

0 Answers   Axtria,


Categories