1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// Card class struct
class Card
{
public:
enum RANK{ ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING}; // RANK variables can only hold the values enumerated here.
enum SUIT{ CLUBS, DIAMONDS, HEARTS, SPADES }; // SUIT variables can only hold the values enumerated here.
Card( RANK rank = ACE, SUIT suit = SPADES, bool isFaceUp = true );
};
// Card ctor
Card::Card( RANK rank, SUIT suit, bool isFaceUp ) : rank ( ACE ), suit (SPADES), isFaceUp (true) {}
// In main
Card cObj1; // Returns rank of ACE
Card cObj2( Card::KING, Card::SPADES, true ); // Returns rank of ACE
cObj2.rank = Card::KING; // Returns rank of KING
|