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!
New course! Every coder should learn Generative AI!
Try a free lesson
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

14th May 2020, 10:25 PM
Intan Suraya
Intan Suraya - avatar
2 Answers
+ 2
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);
14th May 2020, 10:49 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
It works. Thanks!
15th May 2020, 2:53 AM
Intan Suraya
Intan Suraya - avatar