Почему у меня возникает ошибка компоновщика для следующего?Ошибка создания функции шаблона шаблона
template<typename T, typename U>
class A {
public:
class B;
};
template<typename T, typename U>
class A<T, U>::B {
friend bool operator==(const B& b1, const B& b2);
};
template<typename T, typename U>
bool operator==(const typename A<T, U>::B& b1, const typename A<T, U>::B& b2) {
return true;
}
int main() {
A<char, int>::B b1;
A<char, int>::B b2;
if (b1 == b2) {
return 0;
} else {
return 1;
}
}
Ошибки я получаю:
Undefined symbols for architecture x86_64:
"operator==(A<char, int>::B const&, A<char, int>::B const&)", referenced from:
_main in test-qSCyyF.o
Итак ... как исправить это. = P – fumoboy007
Я думал, что это будет obvius :) Я обновлю. – jrok
Так что у меня не может быть функция шаблона друга, которая определена вне класса? – fumoboy007