Page 104 - C++
P. 104

for(int P=Points; P>=100; P--)
          cout<<P<<’#’;
          cout<<endl;
          }
          (i)   103#102#101#100#
          (ii)   100#101#102#103#
          (iii)  104#103#102#101#
          (iv)  103#102#101#100
          2 (a)  What is copy constructor and parameterized constructor? Illustrate with an example.           [2]
          (b)  Answer the questions (i) and (ii) after going through the following class:                      [2]
          class mammal{
          public:
          char category[20];
          mammal( char xname[])                // function1
          {
          strcpy(category, xname)
          }
          mammal(mammal &t);                   //function2
          };

          (i)  Create an object, such that it invokesfunction1.

          (ii)  Write complete definition for function2.
          (c)  Define a class Sports in C++ with following descriptions:                                       [4]
          Private members:
          S_Code        of type long
          S_Name        of type character array (String)
          Fees  of type integer
          Duration      of type integer
          Public members:
          Constructor to assign initial values of S_Code as 1001, S_Name as “Cricket”, Fees as 500, Duration 70
          A function NewSports() which allows user to enter S_Code, S_Name and Duration. Also assign the values to

          Fees as per the following conditions:
                                                      S_Name         Fees
                                                      Table Tennis  2000
                                                      Swimming       4000

                                                      Football       3000
          A function DisplaySports() to display all the details.
          (d)  Consider the following declarations and answer the questions given below:                       [4]

          class NATION

          {

                     int H;
          protected:
   99   100   101   102   103   104   105   106   107   108   109