What actually facilitates the late binding in run time polymorphism?

Is it only the keyword VIRTUAL?

because for example

#include ....

class A
 {
   public:
       virtual void display () = 0;
 };

class B: public A
 {
   public:
       void display ()
         { cout << "B"; }
 };

class C: public A
 {
    public:
        void display ()
           {cout <<"C";}
 };

void main()
 {
   A a;
   B b;
   C c;
   A * ptr[3];
   ptr[0] =  &a;
   ptr[1] =  &b;
   ptr[2] =  &c;

   ptr[1]-> display(); //What's so run time about this?
 }

I mean, it is known quite well that ptr[1] points to an object of type 
B, this information is, according to what i think, available at 
compile time. Or does the keyword VIRTUAL change everything? and if 
that's so, what's the advantage of it run time polymorphism over 
compile time polymorphism???

Please help me with these basics!
   

Reply via email to