Question 82

This question is based on the following C++ code segment and class FUN :

This question is based on the following C++ code segment and class FUN : class FUN { int CODE ; public : FUN ( ); //Function1 FUN (int C); //Function2 FUN (FUN & F); //Function3 void DISP ( ); //Function4 ~FUN ( ); //Function5 }; void main ( ) { FUN F1 ; ______ // BLANK ______ } Which of the following C++ command/ statement can be written in the line marked as BLANK to invoke the function whose prototype is marked as Function 3 ?
  1. AFUN F2;
  2. BFUN F2 (501);
  3. CFUN F2 (F1);
  4. DFUN F2 = F1;
Show answerHide answer

Correct answer: (C) FUN F2 (F1);

Explanation

Function 3, FUN(FUN &F), is the copy constructor, which runs when a new object is made from an existing one, as in FUN F2(F1). (FUN F2 = F1; also calls it, but C is the direct form.)

From DSSSB TGT Computer Science Practice Set 5

This is question 82 of DSSSB TGT Computer Science Practice Set 5. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.