I am a Java programmer migrating to C++ and I am having occasional difficulties understanding the differences between references and pointers. I am getting a compilation error in this context. Here is my code to illustrate the problem and I will be grateful for any assistance.
First of all I am unhappy over the usage of the keyword "this" in my code and I am wondering whether there can be an alternate way to do the same functionality.
Secondly I am not sure where I am going wrong with the pointer assignment.
Aree.cpp: In member function ‘void ATree::foo(Point, double)’:
ATree.cpp:45:37: error: no match for call to ‘(Distance) (Point&, Point&)’
double dist = distance(query,point);
There are only two more files and these look like this. I have not included the full definitions of the code because I am only trying to get the compilation issue resolved. These are just mock ups.
you've got a `distance' object of `Distance' class
the first time you send it a message `.calculateDistance()'
the second time you simply open parenthesis *
¿see the difference?
by the way, there are free functions in c++, you don't need a class for everything.
* I suppose you don't know about operator overloading, you'll be sending the message .operator()