Page 55 - C++
P. 55

int Alter=random(2) + 10 ;
                                            for (int C=0;C<2;C++)
                                            {
                                                   N=random(2) ;
                                                   cout<<Ar[N] +Alter<<”#”;
                                            }
                                    }
                             (i) 21#20#                          (ii) 20#18#
                             (iii) 20#17#                        (iv) 21#17#

             2        (a)    What is a copy constructor? Illustrate with a suitable C++ example.           (2)

                      (b)    Write the output of the following C++ code. Also, write the name of feature   (2)
                             of Object Oriented Programming used in the following program jointly
                             illustrated by the Function 1 to Function 4.
                                    void My_fun ( )                             // Function 1
                                    {
                                            for (int I=1 ; I<=50 ; I++) cout<< "-" ;
                                            cout<<end1 ;
                                    }
                                    void My_fun (int N)                         // Function 2
                                    {
                                            for (int I=1 ; I<=N ; I++) cout<<"*" ;
                                            cout<<end1 ;
                                    }
                                    void My_fun (int A, int B)                  // Function 3
                                    {
                                            for (int I=1. ;I<=B ;I++) cout <<A*I ;
                                            cout<<end1 ;
                                    }
                                    void My_fun (char T, int N)                 // Function 4
                                    {
                                            for (int I=1 ; I<=N ; I++) cout<<T ;
                                            cout<<end1;
                                    }
                                    void main ( )
                                    {
                                            int X=7, Y=4, Z=3;
                                            char C='#' ;
                                            My_fun (C,Y) ;
                                            My_fun (X,Z) ;
                             }

                                                                OR

                             (b) Write any four differences between Constructor and Destructor function
                                 with respect to object oriented programming.


                                                              3
   50   51   52   53   54   55   56   57   58   59   60