Hi,
I want to fill an array with enum Values but using integers in a loop. My set method accepts Enum types and not integers. But when I work with the enums I can use 0,1,2,3 etc.
I am trying to fill a deck of cards using some loops. Is there an easier way to do this than writing loads of code?
enum Suit {Hearts, Clubs, Diamonds, Spades};
enum Value {Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace};
//set method for the type that cards is has the signature:
void set(Value v, Suit s);
void Deck::reset(void) {
int dnumber = 0;
for(int j=0; j<4; j++) {//suit
for (int i=0; i<13; i++) { //value
cards[dnumber].set(i,j); //the compiler doesn't like this line -
dnumber++;
}
}
}
I get this:
error: invalid conversion from `int' to `namespace::Value'
error: invalid conversion from `int' to `namespace::Suit'