Subj : Re: Need help, please! To : borland.public.cpp.borlandcpp From : "Ed Mulroy [TeamB]" Date : Tue Nov 25 2003 07:13 pm Here is the friend function taking two classes as arguments. Yes, it was slow to come about. It was a bit delayed by phone calls. --------------------------- C:\Lookat\q421 >type q421b.cpp class ClassA { private: int iMember; public: ClassA(int i = 0) : iMember(i) {} int Value() const { return iMember; } void Value(int i) { iMember = i; } // Member function removed so that this // does not duplicate an existing function friend ClassA operator - (const ClassA& Obj1, const ClassA& Obj2); }; ClassA operator - (const ClassA& obj1, const ClassA& obj2) { ClassA tmp(obj1.iMember - obj2.iMember); return tmp; } #include using namespace std; int main() { ClassA obj1(5); ClassA obj2(3); ClassA result = obj1 - obj2; // uses friend function cout << "obj1.Value() = " << obj1.Value() << endl; cout << "obj2.Value() = " << obj2.Value() << endl; cout << "obj1.Value() - obj2.Value() using friend = " << result.Value() << endl; return 0; } C:\Lookat\q421 >bcc32 -WCR q421b Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland Q421B.CPP: Turbo Incremental Link 5.64 Copyright (c) 1997-2002 Borland C:\Lookat\q421 >q421b obj1.Value() = 5 obj2.Value() = 3 obj1.Value() - obj2.Value() using friend = 2 C:\Lookat\q421 > --------------------------- .. Ed > Bojidar Markov wrote in message > news:3fc3d0e3@newsgroups.borland.com... .