Dynamic Binding / Virtual Functions
2 posters
Unix C++ :: UNIX CPP :: CPP :: Example Programs
Page 1 of 1
Dynamic Binding / Virtual Functions
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();
}
Dynamic Binding
the other name of dynamic binding is late binding.
Vineet_More- Posts : 27
Points : 31
Join date : 2010-02-26
Unix C++ :: UNIX CPP :: CPP :: Example Programs
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|