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

In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....

2054


Explain bubble sorting.

725


Why do we need c++?

691


Explain the scope of resolution operator.

729


Write about all the implicit member functions of a class?

690






the first character in the variable name must be an a) special symbol b) number c) alphabet

702


How would you use the functions randomize() and random()?

731


What is meant by iomanip in c++?

715


What is setbase c++?

727


Can we specify variable field width in a scanf() format string? If possible how?

755


What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h

701


What are member functions used in c++?

658


What is the full form of ios?

646


What is unary operator? List out the different operators involved in the unary operator.

676


Which format specifier is used for printing a pointer value?

668