What will be the output of following program?


			  		

Loading

Choose the correct option.

What will be the output of following program?

#include 
using namespace std;

class Point
{
int x, y;
public:
Point(const Point &p) { x = p.x; y = p.y; }
int getX() { return x; }
int getY() { return y; }
};

int main()
{
Point p1;
Point p2 = p1;
cout << "x = " << p2.getX() << " y = " << p2.getY();
return 0;
}

A. x = 0  y = 0
B. x = garbage value y = garbage value
C. Compiler Error
D. None of the above

Leave a Comment