← Classes & Objects

Point Distance

easy

Complete Point2D::distanceFromOrigin, a member function that computes how far the point (x, y) is from the origin, using the standard distance formula sqrt(x^2 + y^2).

This is the smallest possible class with real behavior: two public member variables, and one member function that reads them without needing them passed in as parameters – x and y are already in scope inside any of Point2D’s own member functions, because they belong to whichever object the function was called through.

Your solution

"Run" uses the sample stdin ("3 4"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution