← Constructors

Point with Constructor

easy

Add a constructor to Point2D that takes x and y as arguments and initializes the object’s members from them, using the member initializer list – not assignment in the body.

main already calls Point2D p(a, b); – your only job is making that constructor exist. Parameter names px/py (rather than x/y) sidestep needing this-> here, exactly as the lesson noted – that only becomes necessary once a parameter shares a member’s exact name.

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