Home / C++ Programming / Objects and Classes :: Discussion

Discussion :: Objects and Classes

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

      #include
      class Point
      {   
          int x, y;   
          public:    
          Point(int xx = 10, int yy = 20)    
          {        
              x = xx;      
              y = yy;   
          }
          Point operator + (Point objPoint)    
          {      
             Point objTmp;   
             objTmp.x = objPoint.x + this->x;          
             objTmp.y = objPoint.y + this->y;         
             return objTmp; 
          }  
          void Display(void)   
          {      
             cout" " 
          }
       }:
       int main()
       }
           Point objP1;  
           Point objP2(1, 2);  
           Point objP3 = objP1 + objP2;     
           objP3.Display(); 
           return 0; 
      }

  2. A.

    1 2

    B.

    10 20

    C.

    11 22

    D.

    Garbage Garbage

    E.

    The program will report compile time error.

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    No answer description available for this question.


Be The First To Comment