Monday 16 December 2013

Oops with c++

Methods and message passing:

Two or more objects can communicate with each other by sending and receiving messages.
Example:

 The above picture represents the process that is being done in a computer.The monitor,keyboard and cpu interacts with each other by sending some messages in machine level language.

The monitor receives the input by the keyboard through cpu and produces the result.This mechanism is an example for message and method passing.

Dynamic binding:
The process of linking up of procedure call to the code to be executed in response to that call is known as dynamic binding.
Overloading:

The process of providing different meaning to the same module is called overloading.In c++ overloading is achieved by polymorphism.

Generally, polymorphism is classified into two types:


  • Static polymorphism or compile time polymorphism
  1. Function overloading
  2. Operator overloading

  •  Run time polymorphism
  1. Virtual functions
 Function overloading:


  • The same function name having different type or number of arguments
Example:
void add(int,int);
void add(int,float);
void add(int,float,int);
void add(int, double);
In the above prototypes, void is the return type of the function and add is the name of the function and the arguments are listed in brackets

Operator overloading:

      The ability to create new meaning to an existing operator is called as operator overloading.


No comments:

Post a Comment