Page 24 - C++
P. 24

(i)    Give the name of the feature of OOP which is implemented by Function 1 &
                                2 together in the above class Game.

                         (ii)   Anuj made changes to the above class Game and made Function 3 private.
                                Will he be able to execute the Line 1 successfully given below? Justify.

                                                         void main()

                                                         {
                                                                Game ABC;             //Line 1

                                                         }

               Ans       (i)    Polymorphism or Function Overloading or Constructor Overloading
                                (1 mark for correct answer)

                         (ii)   Yes, an error “Destructor for Game is not accessible” will come. As there is a
                                destructor defined in the class and it cannot be made private.

                                (1/2 mark for correct answer Yes)
                                (1/2 mark for correct reason)

               (c)   Define a class Bill in OOP with the following specification:-                                  4

                     Private members:
                         1.  Bill_no              -      type long(bill number)

                         2.  Bill_period          -      type integer(number of months)


                                                         Page No. 7
   19   20   21   22   23   24   25   26   27   28   29