#include <iostream>
// Card class struct
struct Card
{
enum RANK{ ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING };
enum SUIT{ CLUBS, DIAMONDS, HEARTS, SPADES };
Card(RANK rank = ACE, SUIT suit = SPADES, bool isFaceUp = true);
friend std::ostream& operator<<(std::ostream&, const Card&);
private:
static const char* ranks[13];
static const char* suits[4];
RANK rank;
SUIT suit;
bool isFaceUp;
};
const char* Card::ranks [] =
{
"Ace", "Two", "Three", "Four", "Five", "Six", "Seven",
"Eight", "Nine", "Ten", "Jack", "Queen", "King"
};
const char* Card::suits [] = { "Clubs", "Diamonds", "Hearts", "Spades" };
// Card ctor
Card::Card(RANK rank, SUIT suit, bool isFaceUp) : rank(rank), suit(suit), isFaceUp(isFaceUp) {}
std::ostream& operator<<(std::ostream& os, const Card& card)
{
return os << Card::ranks[card.rank - 1] << " of " << Card::suits[card.suit];
}
int main()
{
Card c;
Card d(Card::KING, Card::HEARTS);
std::cout << "c is the " << c << '\n';
std::cout << "d is the " << d << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKLy8gQ2FyZCBjbGFzcyBzdHJ1Y3QKc3RydWN0IENhcmQKewogICAgZW51bSBSQU5LeyBBQ0UgPSAxLCBUV08sIFRIUkVFLCBGT1VSLCBGSVZFLCBTSVgsIFNFVkVOLCBFSUdIVCwgTklORSwgVEVOLCBKQUNLLCBRVUVFTiwgS0lORyB9OyAKICAgIGVudW0gU1VJVHsgQ0xVQlMsIERJQU1PTkRTLCBIRUFSVFMsIFNQQURFUyB9OwoKICAgIENhcmQoUkFOSyByYW5rID0gQUNFLCBTVUlUIHN1aXQgPSBTUEFERVMsIGJvb2wgaXNGYWNlVXAgPSB0cnVlKTsKCiAgICBmcmllbmQgc3RkOjpvc3RyZWFtJiBvcGVyYXRvcjw8KHN0ZDo6b3N0cmVhbSYsIGNvbnN0IENhcmQmKTsKCnByaXZhdGU6CgogICAgc3RhdGljIGNvbn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