LANGUAGES | C++ | C++ INTERVIEW QUESTION AND ANSWERS | 15

C++ Interview Question and Answers - C++ Interview

C++ Interview Question and Answers:

 71.     What is class invariant?
      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.

72.     What is an adaptor class or Wrapper class?
      A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non-objectoriented implementation.

73.     What is the difference between the message and method?
      Message : Objects communicate by sending messages to each other.A message is sent to invoke a method.
Method : Provides response to a message and it is an implementation of an operation.

74.     What is a Null object?
      It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.

No comments:

Post a Comment