What will be the output of the below code?
#include<iostream.h>
class Point {
int x, y;
public:
Point(int i = 0, int j = 0) { x = i; y = j; }
int getX() { return x; }
int getY() { return y; }
};
int main() {
Point p1;
Point p2 = p1;
cout << "x = " << p2.getX() << " y = " << p2.getY();
return 0;
}
x = garbage value; y = garbage value
x = 0; y = 0
Compiler Error
Runtime Error
This question is part of this quiz :
Object Oriented Programming in C++