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

Discussion :: Constructors and Destructors

  1. What will be the output of the following program?

     #include
      class GateBase 
      {    
          public:   
          GateBase()     
          {      
             cout"Base OK. ";     
          }  
          virtual ~GateBase()   
          {      
             cout"Base DEL. ";    
          }
       };
       class GateDerived: public BixBase 
       {     
           public:  
           GateDerived()    
       {        
           cout"Derived OK. ";  
       }   
        ~GateDerived()    
       {      
           cout"Derived DEL. ";   
        }  
     }; 
     int main() 
     {    
          GatetBase *basePtr = new GateDerived();     
          delete basePtr; 
          return 0; 
    }
    

  2. A.

    Base OK. Derived OK.

    B.

    Base OK. Derived OK. Base DEL.

    C.

    Base OK. Derived OK. Derived DEL.

    D.

    Base OK. Derived OK. Derived DEL. Base DEL.

    E.

    Base OK. Derived OK. Base DEL. Derived DEL.

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    No answer description available for this question.


Be The First To Comment