CBSE eBooks CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK
Chapter – 5. CONSTRUCTORS & DESTRUCTORS DELHI 2006 2.b. Answer the following questions (i) and (ii) after going through the following class. 2 class Interview (i) create an object, such that it invokes Constructor 1. Ans: Interview A(10); //invoking constructor 1 by passing a number. (ii) write complete definition for Constructer 2. Ans: Interview(Interview &t) //This is a copy constructor. OUTSIDE DELHI 2006 1.f. What is a default constructor? How does it differ from destructor? 2 Ans: Default constructor: A constructor that accepts no parameter is called the default constructor. With a default constructor, objects are created just the same way as variables of other data types are created. class X Eg: X ob1; Student s1; If a class has no explicit constructor defined, the compiler will supply a default constructor. This implicitly declared default constructor is an inline public members of its class. Declaring a constructor with arguments hides the default constructor. 2.b. Answer the following questions (i) and (ii) after going through the following class. 2 class Exam (i) Create an object, such that it invokes Constructor 1 Ans: Exam E((2008); (ii) Write complete definition for constructor 2. Ans: Exam(Exam &t) //Copy Constructor. |