このコードでリンカー エラーが発生するのはなぜですか? また、どのように修正すればよいですか?
アーキテクチャ x86_64 の未定義のシンボル: "operator==(foo const&, foo const&)"、参照元: main.old の _main: アーキテクチャ x86_64 のシンボルが見つかりません
template<typename T>
class foo {
//friends get access to the private member t
friend bool operator==(const foo<T> &lhs, const foo<T> &rhs);
T t;
};
template<typename T>
bool operator==(const foo<T> &lhs, const foo<T> &rhs) {
return lhs.t == rhs.t;
}
int main(int,char**) {
foo<int> f1, f2;
if (f1 == f2)
;
return 0;
}