未解决的外部C ++ LNK1120

时间:2014-05-03 23:11:47

标签: c++ class templates ostream unresolved-external

我是C ++的初学者。我的模板有问题。 ostream重载可能有问题。

这是我的ostream功能:

        template <unsigned short base_temp>
ostream& operator<< (ostream& ex_123, const Klasa_nk5<base_temp> & klasa)
{
    bool was_digit = 0;
    for (int i = 1; i <= klasa.nk5.size(); ++i)
    {
        if (!(was_digit || int(klasa.nk5[klasa.nk5.size() - i])))  
        {                                                       
            ;
        }
        else
        {
            was_digit = 1;
                ex_123 << int(klasa.nk5[klasa.nk5.size() - i]);
        }
    }

    if (was_digit == 0)
        ex_123 << 0;

    return ex_123;
}

我的班级:

    template <unsigned short base_temp>
class Klasa_nk5
{
private:
    vector<uint8_t> nk5;
    static unsigned int base;
public:
    friend ostream& operator<< (ostream&, const Klasa_nk5 &);
    Klasa_nk5();
    Klasa_nk5(vector<uint8_t> & vector_obtained);
    ~Klasa_nk5();
};

这是错误:

Error   1   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 Klasa_nk5<5> const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$Klasa_nk5@$04@@@Z) 

0 个答案:

没有答案