I'm new to coding, but basically my assignment is to play the card game war and overloading operators to do so. So my question is how to overload the insertion operator when it is a class member function (the assignment says it must be).
My class is as follows:
class Card{
private:
char value;
char suit;
public:
Card(){}
ofstream& operator << (ofstream& COUT)const{
COUT << value << suit;
return COUT;
}
I want to cout << card
(card being of class Card) and it output 7C (as in 7 of clubs) but I get an error at COUT << value
that says
no operator << matches these operands
operand types are: std::ofstream << char
I'm not sure if I set up the overloading function correctly or if it is another issue. There is more in class Card but they don't relate to the problem I'm having.