code is not compiling

Posted by user323422 on Stack Overflow See other posts from Stack Overflow or by user323422
Published on 2010-04-27T13:04:40Z Indexed on 2010/04/27 13:13 UTC
Read the original article Hit count: 204

Filed under:
template< class Type ,int Size = 3>

class cStack
{
    Type *m_array;
    int m_Top;
    int m_Size;

public:cStack();
       friend std::ostream& operator <<(std::ostream &, const cStack<Type,Size> &);
};

template< class Type ,int Size >
std::ostream& operator << ( std::ostream &os, const cStack<Type,Size> &s)
{
    for( int i=0; i<=s.GetTop();i++)
    {
        os << s.m_array[i];
    }
    return os;
}

on compilin it showing following error

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 cStack<int,3> const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$cStack@H$02@@@Z) referenced in function _main

© Stack Overflow or respective owner

Related posts about c++