First, unless it is in the definition of a class--it's a non-member. Friend has nothing to do with it. So, you want a stand alone overloaded operator. Example:
Code:
#include "Rock.hpp" // The Rock class
#include <iostream>
bool operator==(const Rock &, const Rock &);
bool operator==(const Rock & x, const Rock & y) { return (x==y); }
int main(int argc, char **argv){
Rock rock1, rock2;
// Assign values to rock1 & rock2 here.
cout << "rock1 == rock2? "
<< (rock1 == rock2 ? "Yes" : "No")
<< endl;
} // End main()
Bookmarks