Friend methods error

I get this error message:

'friend' used outside of class.

My header has this line

private:
        friend ostream& operator << (ostream&, card&);

and in the cpp file it is

friend ostream& operator << (ostream& outStream, card& card)
{
    Suit suit=card.getSuit();
    Rank rank=card.getRank();
    string str;
    switch(rank)
        { /*...*/ }
    outStream<<str;
    return outStream;

like this.

I searched but mostly it says that I need same class without friend but I tried, and it did not work. Can you please give me some suggestion?

Thank you

Leave a Comment