Wednesday 3 September 2014

DYNAMIC BINDING (LATE BINDING)

DYNAMIC BINDING

 
We study about the Dynamic Binding  and Binding refers to the linking of a procedure call to the code to be executed in response to the call. It is also known as Late Binding.When the variable are assigned value at  the run-time then it is known as Late Binding. Now lets see a example of Dynamic Binding
 
 
#include<iostream.h>
#include<conio.h>
 
class test
{
int a, b, c;
 
public:
void get(int i , int j, int k)
{
a=i;
b=j;
c=k;
}
 
void show()
{
cout<<a<<b<<c;
}
};
 
void main()
{
int  i, j, k;
test t;
cout<<"Enter the value of numbers";
cin>>i>>j>>k;
t.get();
t.show();
getch();
}
 
This example We have a class test and in which we have two functions get()and show() and we have three  variable a, b, c and we are assigned the value at the run-time.
 

EARLY BINDING

When variable are assigned value at the design this is known as Early Binding.lets take a example of
Early Binding.
 
 
 
#include<iostream.h>
#include<conio.h>
 
class test
{
int a, b, c;
 
public:
void get()
{
a=100;
b=300;
c=400;
}
 
void show()
{
cout<<a<<b<<c;
}
};
 
void main()
{
test t;
t.show();
getch();
}
 
 
 

 

 

No comments:

Post a Comment