Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Dynamic Binding / Virtual Functions

2 posters

Go down

Dynamic Binding / Virtual Functions Empty Dynamic Binding / Virtual Functions

Post by Christopher 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();
}

Christopher
Christopher
Admin

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

https://unixcpp.forumotion.com

Back to top Go down

Dynamic Binding / Virtual Functions Empty Dynamic Binding

Post by Vineet_More 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

Back to top Go down

Back to top

- Similar topics

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