Page 183 - DCAP404 _Object Oriented Programming
P. 183

Object-oriented Programming




                    Notes                 int  age;
                                          char  name  [20];
                                          public;
                                                 void  get();
                                                 void  show();
                                          }
                                          void  worker:  get()
                                          {
                                                 cout  <<  “your  name  please”;
                                                 cin  >>  name;
                                                 cout  <<  “your  age  please”;
                                          }
                                          void  worker::show()
                                   {
                                          cout  <<  “In  my  name  is  :  “<<name<<“  In  my  age  is  :  “<<age;
                                          }
                                          class  manager  :  public  worker   //Intermediate  base  class  derived
                                          {                            //publicly  from  the  base  class
                                          int  now;
                                          public:
                                                 void  get();
                                                 void  show();
                                          };
                                          void  manager::get()
                                          {
                                          worker::get();               //calling  get  (  )  fn.  of  base  class
                                          cout  <<  “no.  of  workers  under  you:”;
                                          cin  >>  now;
                                          }
                                          void  manager  :  :  show  (  )
                                          {
                                          worker  :  :  show  (  );    //calling  show  (  )  fn.  of  base  class
                                          cout  <<  “In  no.  of  workers  under  me  are:  “<<  now;
                                          }
                                          class  ceo:  public  manager        //declaration  of  derived  class
                                          {                                   //publicly  inherited  from  the
                                          int  nom;                           //intermediate  base  class
                                          public:
                                                 void  get  (  );
                                                 void  show  (  );
                                          }
                                                 void  ceo  :  :  get  (  )



          176                               LOVELY PROFESSIONAL UNIVERSITY
   178   179   180   181   182   183   184   185   186   187   188