Home / C++ Programming / Constructors and Destructors :: Discussion

Discussion :: Constructors and Destructors

  1. Which of the following statement is correct about the program given below?

      #include
       class FresherGate 
       {   
            int x;  
            public:      
                FresherGate()      
                {          
                   x = 0;      
                }         
                FresherGate(int xx)        
                {        
                    x = xx;       
                }         
                FresherGate(FresherGate &objB)      
                {     
                   x = objB.x;   
                }     
                void Display()   
                {       
                    cout" ";   
                }
      };
      int main()
      {    
           FresherGate objA(25);  
           FresherGate objB(objA);    
           FresherGate objC = objA;      
           objA.Display(); 
           objB.Display();  
           objC.Display();  
           return 0;  
    }
    

  2. A.

    The program will print the output 25 25 25 .

    B.

    The program will print the output 25 Garbage 25 .

    C.

    The program will print the output Garbage 25 25 .

    D.

    The program will report compile time error.

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    No answer description available for this question.


Be The First To Comment