Code /* testEnum.cpp David G. Klick CIS 250 2006-02-20 Demonstrates use of enumerations. */ #include #include using std::cout; using std::string; using std::ostream; enum SUIT { Spades, Clubs, Hearts, Diamonds }; enum RANK { Ace=1, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King }; string Suit[4] = { "Spades", "Clubs", "Hearts", "Diamonds" }; string Rank[13] = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" }; class card { public: RANK rank; SUIT suit; friend ostream& operator<<(ostream& strm, const card& c) { strm << Rank[c.rank-1] << " of " << Suit[c.suit]; return strm; } }; int main(void) { card c; c.rank = Jack; c.suit = Spades; cout << c << '\n'; c.rank = static_cast(1); c.suit = static_cast(2); cout << c << '\n'; return 0; }