Y
Yoon-Soo Lee
I am using Visual C++ .NET 2003 and running into some linking error from the
following template code.
The error messages is
error LNK2019: unresolved external symbol "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
operator<<(class std::basic_ostream<char,struct std::char_traits<char> >
&,class Test<int> &)"
(??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@AAV?$Test@H@@@Z
) referenced in function _main
#include <iostream>
using namespace std;
template <class object>
class Test {
private:
object T;
public:
Test(object x): T(x) {};
friend ostream & operator << (ostream & out_stream, Test &test);
};
template <class object>
ostream & operator << (ostream & out_stream, Test<object> &test) {
out_stream << test.T ;
return out_stream;
}
cannot figure out what the problem is. Am I writing my template wrong or
what?
following template code.
The error messages is
error LNK2019: unresolved external symbol "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
operator<<(class std::basic_ostream<char,struct std::char_traits<char> >
&,class Test<int> &)"
(??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@AAV?$Test@H@@@Z
) referenced in function _main
#include <iostream>
using namespace std;
template <class object>
class Test {
private:
object T;
public:
Test(object x): T(x) {};
friend ostream & operator << (ostream & out_stream, Test &test);
};
template <class object>
ostream & operator << (ostream & out_stream, Test<object> &test) {
out_stream << test.T ;
return out_stream;
}
cannot figure out what the problem is. Am I writing my template wrong or
what?