I am trying to write this such that [teaching c++ online course]:
1) reads a Cartesian point
2) calculates distance from origin
3) finds distance compared to last point
4) outputs one which is closer
5) if point within 0.01 to origin it terminates.
However when I compile it says: " d1 was not declared in this scope : line 34"
No. Variables aren't created in function declarations, and line 10 isn't a declaration anyway; it's the invocation of a function (though one with incorrect syntax).
If you wish line 10 to be a function declaration, remove the assignment: