Вот мой код:
#include<iostream>
class foo;
template<typename T> void bar(T a) { std::cout<< a.var; }
class foo {
int var;
public:
friend void bar(foo); //here, bar function template is declared in global namescope,
// deduction can deduce which template instance we're talking about.
//Note: If I place <> just after name bar or qualify bar like ::bar , it all works then.
};
int main() {
foo fooo;
bar(fooo);
}
ошибка: /home/O1wLF2/cc1xOI20.o: в функции 'main': prog.cpp :(. Text + 0x46): неопределенная ссылка на 'bar(foo) '
Что я хочу знать, почему экземпляр неквалифицированной шаблонной функции не может быть другом?