Member functions can be simply called in one of two ways. If the function is declared as static then you call it using the scope resolution operator and the name of the class:
class C {
public:
static void foo();
};
// ...
C::foo(); If the member function is not declared as static then you must call it using the member access operator and anobject of the class:
class C {
public:
void foo();
};
// ...
C obj;
obj.foo(); In your case, the line in question should be changed to:
cout << "the distance is" << pt1.getDistance(pt2); Alternatively you could say:
cout << "the distance is" << pt2.getDistance(pt1); Because this shouldn't effect the distance between the two points. The key is understanding that at least one of the objects passed to perimeter should be used as the base object that you call getDistance on and the other object should be passed as the argument to getDistance.
Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401