Thursday, 26 May 2011

C++ program part1

  1. What is an object in C++?
    An object is a package that contains related data and instructions. The data relates to what the object represents, while the instructions define how this object relates to other objects and itself.

  2. What is a message?
    A message is a signal from one object to another requesting that a computation take place. It is roughly equivalent to a function call in other languages.

  3. What is a class?
    A class defines the characteristics of a certain type of object. It defines what its members will remember, the messages to which they will respond, and what form the response will take.

  4. What is an instance?
    An individual object that is a member of some class.

  5. What is a super-class?
    Given a class, a super-class is the basis of the class under consideration. The given class is defined as a subset (in some respects) of the super-class. Objects of the given class potentially posses all the characteristics belonging to objects of the super-class.

  6. What is inheritance?
    Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it. The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class.

  7. To what does message protocol refer?
    An object's message protocol is the exact form of the set of messages to which the object can respond.

  8. What is polymorphism?
    Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol, containing differing types of objects. Consider 1 + 5 and 1 + 5.1. In the former, the message "+ 5" is sent to an object of class integer (1). In the later, the message "+ 5.1" is sent to the same integer object. The form of the message (its protocol) is identical in both cases. What differs is the type of object on the right-hand side of these messages. The former is an integer object (5) while the later is a floating point object (5.1). The receiver (1) appears (to other objects) to respond in the same way to both messages. Internally, however, it knows that it must treat the two types of objects differently in order to obtain the same overall response.

No comments:

Post a Comment