Home / C++ Programming / Functions - C++ :: Discussion

Discussion :: Functions - C++

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

    
      #include
      class Base
      {    
          int x, y;   
          public:   
          Base()     
          {         
              x = y = 0;    
           }      
           Base(int xx)     
           {      
               x = xx;   
          }   
          Base(int p, int q = 10)   
          {     
              x = p + q;      
              y = q;     
          }     
          void Display(void)    
          {       
             cout" " 1, 1);  
     
      class Derived: public Base
      {    
          Base obj;   
          public:   
          Derived(int xx, int yy): Base(xx, xx + 1)    
          { }     
          Derived(Base objB = objDefault)   
          { }  
     };
     int main()
     {
         Derived objD(5, 3);  
         Derived *ptrD = new Derived(objD);  
         ptrD->Display();   
         delete ptrD;    
         return 0; 
     }
    

  2. A.

    3 2

    B.

    8 3

    C.

    11 6

    D.

    11 10

    E.

    The program will not compile successfully.

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    No answer description available for this question.


Be The First To Comment