CBSE eBooks CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK
Chapter – 5. CONSTRUCTORS & DESTRUCTORS (i) Name the specific features of class shown by member Function 1 and Member Function 2 in the above example. Ans: Member function 1 is a (non-parameterized or default) constructor (, which will be executed automatically at the time of creation of an object of class Maths). Member function 2 is a destructor (,which will be executed automatically at the time of destruction of an object of class Maths). (ii) How would Member Function 1 and Member Function 2 get executed ? Ans: They will be executed automatically. Member function 1 will be executed at the time of creation of an object of class Maths. Member function 2 will be executed at the time of destruction of an object of class Maths. 2. c. Define a class Tour in C++ with the description given below4 Private Members:
Public Members: • A constructor to assign initial values as follows: • A function AssignFare() which calculates and assigns the value of the data member Totalfare as follows For each Adult Fare (Rs) For each Kid the above Fare will be 50% of the Fare mentioned in the above table For Example: • A function EnterTour() to input the values of the data members TCode, NoofAdults, NoofKids and Kilometers ; and invoke the AssignFare() function. • A function ShowTour() which displays the content of all the data members for a Tour. |