The answer to your real question is not explained for the reasons indicated in the @AndyProwl link, and even if you included the operator definitions inside the header util.h, the answer will still be.
, , , . ,
template<class T>
struct Rect {
T x, y, w, h;
friend bool operator ==(const Rect<T> &a, const Rect<T> &b);
friend bool operator !=(const Rect<T> &a, const Rect<T> &b);
};
T
bool operator ==(const Rect<T> &a, const Rect<T> &b);
bool operator !=(const Rect<T> &a, const Rect<T> &b);
template<class T>
bool operator ==(const Rect<T> &a, const Rect<T> &b)
{
return (a.x == b.x && a.y == b.y && a.w == b.w && a.h == b.h);
}
template<class T>
bool operator !=(const Rect<T> &a, const Rect<T> &b)
{
return !(a == b);
}
, - , , - . , .
: in-class ( ) ( , @AndyProwl), peculair
template<typename T> struct Rect;
template<typename T> bool operator==(const Rect<T>&, const Rect<T>&);
template<typename T> bool operator!=(const Rect<T>&, const Rect<T>&);
template<class T>
struct Rect {
T x, y, w, h;
friend bool operator == <>(const Rect<T> &a, const Rect<T> &b);
friend bool operator != <>(const Rect<T> &a, const Rect<T> &b);
};
, - , Herb Sutter.