How's the definition of the function dist(const point& p) should be if I wish to set the return type of the function as double? | SoloLearn: Learn to code for FREE!

0

How's the definition of the function dist(const point& p) should be if I wish to set the return type of the function as double?

https://code.sololearn.com/c8uJcMAEmpE0/?ref=app

c++

5/14/2020 10:25:46 PM

Intan Suraya

2 Answers

New Answer

+1

Just remove void and change to a double by uncommenting double where you have it. Then in the dist function remove the cout and uncomment the return of d. double dist(const point& p); double point::dist(const point& p) { ..... return d; } Then in main change your cout so that the returned value is put into the output stream. cout << " : " << p1.dist(p2);

+1

It works. Thanks!