Friday, 29 June 2012

How To Implement Concept Of Virtual Function


#include<iostream.h>
#include<conio.h>
 class base
 {
 public:
  virtual void show()
  {


   int a=10;
    cout<<a;
  }
 };
  class der:public base
  {
     public:
     void show()
     {
       int b=20;
       cout<<b;
     }
  };
 void main()
 {
  clrscr();
   base *ptr;
   der k;
   ptr=&k;
   ptr->show();
  getch();
 }

No comments:

Post a Comment