CBSE eBooks CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK
Chapter – 5. CONSTRUCTORS & DESTRUCTORS DELHI 2005 2.b. Answer the following questions (i) and (ii) after going through the following class. class Test (i) Which feature Object Oriented Programming is demonstrated using Function 1, Function 2, Function 3 and Function 4 in the above class text? Ans: Function overloading (here it is constructor overloading). (ii) Write statements in C++ that would execute Function 2 and Function 4 of class Text. Ans: (let char name[20]; int X=60; strcpy(name,”COMPUTERSCIENCE”); are declared in the program) (i) Test A(name); //Will execute Funciton 2 2.c. Define a class Travelplan in C++ with the following descriptions: Private Members:
Public Members: *A constructer to assign initial values of PlanCode as 1001, Place as “agra”,Number_of_travellers as 5,Number_of_buses as 1 * A function NewPlan() which allows user to enter PlanCode, Place and Number_of travelers. Also, assign the value of Number_of_buses as per the following conditions:
* A function ShowPlan() to display the3 content of all the data members on the screen. |