Page 202 - DCAP404 _Object Oriented Programming
P. 202

Unit 9: Inheritance




                                void  get  (int);                                               Notes
                                void  show  (void);
                         };
                         void  A1  ::  get  (int  a)
                                {  y  =  a;]
                         void  A1  ::  show  (void)
                         {

                         cout  <<y;
                         {
                         class  A2  :  Virtual  public  A
                         {
                         protected:
                                int  z;
                         public:

                                void  get  (int  a)
                                {  z  =  a;}
                                void  show  (void)
                                {  cout  <<  z;]
                         };
                         class  A12  :  public  A1,  public  A2
                         {
                         int  r,  t;
                         public:

                                void  get  (int  a)
                                {  r  =  a;}
                                void  show  (void)
                                { t = x + y + z + r;
                                       cout  <<  “result  =”<<  t;
                                }
                         };

                         main  (  )
                         {
                         clrscr  (  );
                                A12  r;
                                r.A  :  :  get  (3);
                                r.A1:  :  get  (4);
                                r.A2  :  :  get  (5);




                                           LOVELY PROFESSIONAL UNIVERSITY                                   195
   197   198   199   200   201   202   203   204   205   206   207