i have a class which needs to implement the operator== and return type of it is bool. I'm not sure is below code the correct way to implement it.
//MyTest.hpp file
class Test {
public:
Test();
virtual ~Test();
int x,y;
bool operator==(const Test &v);
};
// MyTest.cpp file
bool Test::operator==(const Test &v) {
return (x== v.x) && (y==v.y);
}
even though the code compiles is this standard way to implement we need to use template. Should i use template way of implementation like below code :
template <class T>
bool operator==(const T &v);