This code compiles without errors or warnings:
#include#include using namespace std; class Point { public: Point(int x, int y) : x_(x), y_(y) {} string toString() { string result("("); return result + to_string(x_) + ", " + to_string(y_) + ")"; } int &x_; int &y_; }; int main() { int x = 1; int y = 2; Point p(x,y); cout << "First p = " << p.toString() << endl; x = 10; y = 20; cout << "Second p = " << p.toString() << endl; int qx = 100; int qy = 200; Point q(qx, qy); cout << "Third p = " << p.toString() << endl; cout << "First q = " << q.toString() << endl; return 0; }
(1) What does it print?
$ ./a.out First p = (1, 2) Second p = (0, 6304064) Third p = (100, 200) First q = (0, 6304064)(B) Why does it print that?