Friday, 16 May 2014

Concepts of OOPs-5 or Characteristics of OOPs



                  Concepts of OOPs-5

Creating New Data Types
OOP provides facility to the programmer to create new data types. For example, suppose we are working with complex numbers in program. We want to express operations on complex numbers with normal arithmetic operations, such as
                                C 3 = C 1 + C 2;
Where C1, C2 and C3 are the complex numbers. In OOP, by creating a class that incorporates these values and declaring C1, C2 and C3 to be object of this class, we can create a new data type.
 This feature is also implemented by the operator overloading. This feature brings the programming close to real world.

Message Passing
An object-oriented program consists of a set of objects that communicate with each other, the same way as people communicate with each other, Basic steps in OOP are:
1. Create classes
2. Create objects from class definitions
3. Establishing communication among objects

Once an object has been created, we need to interact with it. To do this, use its member functions, that is, the functions described in the class specification. We call an object’s member function. This is the same as saying we pass a message to the object.
 When we pass a message to an object, there are two things to consider.
1. Which object are you communicating with?
2. What message are you sending to the object? This is the same as asking which of the object’s member function you are calling.
Therefore, syntax of message passing has two parts; the name of the object and the name of the member function as shown in the figure below:
 The object name and the function name are connected by the period (.), which is called the dot operator or the class member access operator.

No comments:

Post a Comment