Page 148 - C++
P. 148

N=random(2);
                    cout<<Arr[N]+Chance<<”#”;
                    }
                     (i)  9#6#
                    (ii)  19#17#
                    (iii)  19#16#
                    (iv)  20#16#
              2. (a)  What is the difference between nesting or containership and inheritance? Explain with example?
                                                                                                        [2]
                (b)  Answer the question (i) and (ii) after going through the following class:          [2]
                   class Travel
                    {
                    intPlaceCode; char Place[20]; float Charges;
                    public:
                    Travel( ) //Function 1
                    {
                    PlaceCode=1; strcpy(Place,”DELHI”);Charges=1000;
                    }
                    voidTravelPlan(float C ) // Function 2
                    {
                    cout<<PlaceCode<<“:”<<Place<<”:”<<Charges<<endl;
                    }
                    ~Travel( ) // Function 3
                    {
                    cout<<”Travel Plan Cancelled”<<endl;
                    }
                    Travel(intPC,char p[ ],float C) // Function 4
                    {
                    PlaceCode=PC;strcpy(Place,P);Charges=c;
                    }
                    };
                    (i)  In Object Oriented Programming, what is Function 1 and Function 4 combined together
                       referred as?
                    (ii)  In Object Oriented Programming, which concept is illustrated by Function 3? When is this
                       function called/invoked?
                (c)  Define a class report with the following specification:                            [4]
                    Private members:
                    adno 4 digit admission number
                    name 20 characters
                    marks an array of 5 floating point values
                    average marks obtained
                    getavg() to compute the average obtained in five subjects
                    Public members:
                    read info() function to accept values for adno, name, marks, and invoke the function getavg().
                    display info() function to display all data members on the screen you should give function
                   definitions.
              Model Test Papers                                                                      MTP.3
   143   144   145   146   147   148   149   150   151   152   153