Original Post
I write some codes like this: But the compiler always pops: Linking... cpptest.obj : error LNK2001: unresolved external symbol "void __cdecl show_test(class test &)" (?show_test@@YAXAAV?$test@H@@@Z) what's wrong here?
template<class T>
class test
{
vector<int> v;
public:
test()
:v(10, 1)
{}
friend void show_test(test<T>&);
};
template<class T>
void show_test(test<T>& t)//friend function of test
{
for(unsigned short i = 0; i < t.v.size(); ++i)
cout << t.v << " ";
cout << endl;
}
void demo_test()
{
test<int> t;
show_test(t);
}
int main()
{
demo_test();
return 0;
}