Dynamic Binding / Virtual Functions

Go down

Dynamic Binding / Virtual Functions

Post by Christopher on Wed Mar 03, 2010 10:41 am

Virtual function is a mechanism to implement the concept of polymorphism. Virtual Functions are resolved during run-time. It is called dynamic binding.

Code:
#include<iostream>

using namespace std;

class Base
{
public:

   virtual void disp()
   {
      cout<<"Base disp function";
   }
};

class Derived:public Base
{

public:

   void disp()
   {
      cout<<"Derived disp function";
   }
};

int main()
{
   Base *b=new Derived;
   b->disp();
}

avatar
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 30

View user profile http://unixcpp.forumotion.com

Back to top Go down

Dynamic Binding

Post by Vineet_More on Wed Mar 03, 2010 11:49 am

the other name of dynamic binding is late binding.

Vineet_More

Posts : 27
Points : 31
Join date : 2010-02-26

View user profile

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum