Page 191 - DCAP404 _Object Oriented Programming
P. 191

Object-oriented Programming




                    Notes                        protected:
                                                        int  r_no;
                                                 public:
                                                        void  get  _n  (int  a)  {
                                                               r_no  -  a;  }
                                                        void  put_n  (void)
                                                        {

                                                        cout  <<  “Roll  No.:  “<<  r_no;
                                                        cout  <<  “In”;
                                                        }
                                                 };
                                                 class  test  :  public  student
                                                 {                                   //Intermediate  base  class
                                                 protected  :  int  part1,  par  2;  //(base  for  result)

                                                 public  :
                                                        void  get_m  (int  x,  int  y)  {
                                                               part1  =  x;  part  2  =  y;  }
                                                        void  put_m  (void)  {
                                                               cout  <<  “marks  obtained:  “<<  “In”
                                                                       <<  “Part  1  =  “<<  part1  <<  “In”
                                                                       <<  “Part  2  =  “<<  part2  <<  “In”;
                                                        }
                                                 };

                                                 class  sports                //  base  for  result
                                                 {
                                                 protected  :  int  score;
                                                 public:
                                                        void  get_s  (int  s)  {
                                                               score  =  S1  }
                                                        void  put_s  (void)  {

                                                               cout  <<  “sports  wt.  :  “<<  score  <<  “\n\n”;
                                                        }
                                                 };
                                                 class  result  :  public  test,  public  sports//Derived from test
                                                                                                       &  sports
                                                 {
                                                 int  total;




          184                               LOVELY PROFESSIONAL UNIVERSITY
   186   187   188   189   190   191   192   193   194   195   196