New course! Every coder should learn Generative AI!
Try a free lesson0
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?
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);
+ 1
It works. Thanks!