Possible Duplicates:
Enumerate over an enum in C++
C++: Iterate through an enum
I've have a card class for a blackjack game with the following enums:
enum Rank { Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King };
enum Suit { Clubs, Diamonds, Hearts, Spades };
When I create the deck I want to write the code like this:
// foreach Suit in Card::Suit
// foreach Rank in Card::Rank
// add new card(rank, suit) to deck
I believe there is no foreach in c++. However, how do I traverse an enum?
Thanks, Spencer