What is class invariant?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by friend class & friend function in c++?

615


If there are two catch statements, one for base and one for derived, which should come first?

567


When should overload new operator on a global basis or a class basis?

606


What is the return value of the insertion operator?

597


What is iomanip c++?

592






Is c++ a difficult language?

566


Is c++ the most powerful language?

558


Perform addition, multiplication, subtraction of 2-D array using Operator Overloading.

3364


What are single and multiple inheritances in c++?

570


Is it possible to write a c++ template to check for a function's existence?

568


What is public, protected, private in c++?

642


How can you link a c program with a c function?

556


What is ostream in c++?

563


Is there a sort function in c++?

543


What is do..while loops structure?

611