const
Objects¶
Given the following (incomplete) class definition ..
class point
{
public:
int x() const { return _x; }
};
Question 1¶
Would the following code snippet compile?
const point p(1,2);
cout << p.x() << endl;
Yes |
No |
---|---|
Question 2¶
Would the following code snippet compile?
point p(1,2);
cout << p.x() << endl;
Yes |
No |
---|---|