Page 181 - DCAP404 _Object Oriented Programming
P. 181

Object-oriented Programming




                    Notes                        void  worker::show()
                                                 {
                                                 cout  <<  “\n  My  name  is:  “<<  name  <<  “\nMy  age  is  “<<age
                                                 }
                                                 class  manager  :  protected  worker  //  protected  inheritance
                                                 {
                                                        int  now;
                                                 public:
                                                        void  get();
                                                        void  show();
                                                 };
                                                 void  manager::get()
                                                 {
                                                        cout  <<  “please  enter  the  name\n”;
                                                        cin  >>  name;
                                                        cout  <<  “please  enter  the  age\n”;
                                   //Directly  inputting  the  data
                                                        cin  >>  age;
                                   //members  of  base  class
                                                        cout  <<“  please  enter  the  no.  of  workers  under  you:”;
                                                        cin  >>  now;
                                                 }
                                                 void  manager::show()
                                                 {
                                                 cout  <<  “your  name  is  :  “<<name<<“  and  age  is  :  “<<age;
                                                 cout  <<“\n  no.  of  workers  under  your  are  :  “<<now;
                                                 main()
                                                 {
                                                        clrscr();
                                                        manager  m1;
                                                        m1.get();
                                                        cout  <<  “\n  \n”;
                                                        m1.show();
                                                 }




                                      Task  In a group of four try to analyze the advantages of single inheritance.








          174                               LOVELY PROFESSIONAL UNIVERSITY
   176   177   178   179   180   181   182   183   184   185   186