I use visual c++. I have a template class and I want add overlapped operation for it I impelement it like below in header file
template <class T> class QuantityT;
template <class T>
inline std::ostream & operator<< (std::ostream & os,const QuantityT<T> &quantity);
template <class T>
class QuantityT{
T quantity_;
template<class T> friend inline std::ostream & operator<< <T>(std::ostream & os,const QuantityT<T> &quantity);
};
in souce file
template <class T>
inline std::ostream & operator<< (std::ostream & os,const QuantityT<T> &quantity){
}
but I get link error:
main.obj : error LNK2019: unresolved external symbol "class std::basic_ostream > & __cdecl operator<<(class std::basic_ostream > &,class QuantityT const &)" (??$?6K@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$QuantityT@K@@@Z) referenced in function "public: virtual void __thiscall log::print(class std::basic_ostream
&)const " (?print@log@@UBEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z
How I can fix it?