5. Explain why the following member function of class Point does not compile: constexpr double Distance(const Point&

Question:

5. Explain why the following member function of class Point does not compile:

constexpr double Distance(const Point& pt2) const

{

return std::sqrt((x - pt2.x)*(x - pt2.x) + (y - pt2.y)*(y - pt2.y));

}

Furthermore, does the following code compile?

constexpr Point p2(1.0, 2.0);

double newVal = 3.0;

p2.X(newVal);

Point p3(1.0, 2.0);

double newVal2 = 3.0;

p3.X(newVal2);

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: