C++ 类模板中的友元函数和错误LNK2019

C++ 类模板中的友元函数和错误LNK2019,c++,class,templates,overloading,operator-keyword,C++,Class,Templates,Overloading,Operator Keyword,我正在尝试重载运算符您的代码中有两个问题,第一个是,您应该移动运算符的实现简短回答:您必须移动运算符的实现。这有助于解决错误LNK2019,谢谢。A不知道我怎么错过了!当然,模板覆盖操作符意味着它是模板,应该在.h文件中。。。。但现在我有了“错误”接线员是的,现在我知道了。我在几分钟前解决了我的问题,但谢谢你的回答。:) NSizeNatural<30> a(101); cout << a; error LNK2019: unresolved external symb

我正在尝试重载运算符
您的代码中有两个问题,第一个是,您应该移动
运算符的实现简短回答:您必须移动
运算符的实现。这有助于解决错误LNK2019,谢谢。A不知道我怎么错过了!当然,模板覆盖操作符意味着它是模板,应该在.h文件中。。。。但现在我有了“错误”接线员是的,现在我知道了。我在几分钟前解决了我的问题,但谢谢你的回答。:)
NSizeNatural<30> a(101);
cout << a;
error LNK2019: unresolved external symbol "class   std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<<30,unsigned int,unsigned __int64,10>(class std::basic_ostream<char,struct std::char_traits<char> > &,class NSizeNatural<30,unsigned int,unsigned __int64,10> const &)" (??$?6$0BO@I_K$09@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?    $NSizeNatural@$0BO@I_K$09@@@Z) referenced in function _main
template<int size, typename basic_type = unsigned int, typename long_type = unsigned long long, long_type base = bases(DEC)> 
class NSizeNatural
{
       // this is how I decelerate friend function  
     friend ostream& operator<<(ostream& str, const NSizeNatural<size, basic_type, long_type, base> & n);
}
template<int size, typename basic_type, typename long_type, long_type base>
std::ostream& operator<<(std::ostream& out, const NSizeNatural<size, basic_type,   long_type, base> &y)
{
   // For now i want to have my code compile-able 
   return out << "gg"; 
}
template<int size, typename basic_type = unsigned int, typename long_type = unsigned long long, long_type base = bases(DEC)>
class NSizeNatural
{
    template<int size1, typename basic_type1, typename long_type1, long_type base1>
    friend ostream& operator<< (ostream& str, const NSizeNatural<size, basic_type, long_type, base> & n);
};