I have a class SomeClass
and I wish to implement an overloaded ==
to compare two instances of this class.
The overloaded ==
does not make use of any of SomeClass
's private members. So, it does not have to be a friend
.
How do I make it a non-member, non-friend function?
Currently, this is what my code looks like:
someclass.h
#ifndef SOMECLASS_H
#define SOMECLASS_H
class SomeClass
{
public:
// Other class declarations, constructors
friend bool operator==(const SomeClass a, const SomeClass b);
};
someclass.cpp
#include "someclass.h"
// Other stuff
bool operator==(const SomeClass a, const SomeClass b) {
// do some comparison and return true/false
}