Overloading the >> operator problem splitting the input

Hi,

I am trying to overload the input operator in the following manner:

I have a playing card class that that contains two private members: rank stores the value of a card, suit stores the suit of the card.

The >> operator should accept cards in the following manner:

examples:

7S
KH
3D

where 7S represents the 7 of spades
where KH represents the king of hearts
where 3D represents the 3 of diamonds

For the first example, internally, this would occur within an object of the playing card class:

rank = Seven
suit = Spades

I have created two enum types to use:

enum Rank {Two ... Ace};
enum Suit {Spades ... Hearts};

So my challenge is I am unsure as how to split that one value from stdin into two usable values

istream& operator>> (istream& in, Card& c)
{
in >> c; //Need help with implementation
return in;

}
Topic archived. No new replies allowed.