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 ?
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.)