In fact, "distance( )" is a function defined within the "std" name-space. And, by "using namespace std", you will cause a conflict between "std::distance( )" and "::distance( )". I advise that you change the name of your "distance" function.
Also, in your "distance( )" function, the last "return" statement will never be executed because another "return" shadows it.
a) Post line where eror occured
b) There is numerous problems in your code:
1) distance() defined as void, but you are trying to return value from it
2) You are trying to return twice. Why?
3) You have probably run into naming collision with std::distance function
c) there is std::hypot() in <cmath> which does exactly what your function does