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

Where and why do I have to put the "template" and "typename" keywords?

0 Answers  


Is overriding possible in c++?

0 Answers  


What is nested class in c++?

0 Answers  


How can we access protected and private members of a class?

0 Answers  


Describe public access specifiers?

0 Answers  






List the issue that the auto_ptr object handles?

0 Answers  


What is code reusability in c++?

0 Answers  


How would you represent an error detected during constructor of an object?

1 Answers  


What is difference between shallow copy and deep copy? Which is default?

1 Answers  


What is #include iostream in c++?

0 Answers  


What is a dangling pointer in c++?

0 Answers  


How to access a variable of the structure?

0 Answers  


Categories