Actually I think you are maybe wrong... because 13x4=52...
Actually I think you are maybe wrong... because 13x4=52...
Sometimes I forget what I am doing when I enter a room, actually, quite often.
Code:class Deck { public: Deck() { int x; int y; int z = 0; for (y = 0; y < 4; y++) { for (x = 0; x < 13; x++) { Cards[z].suit = y; Cards[z].value = x; z++; } } } //private: Card Cards[52]; };
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
But 4 * 14 is 56!
And your second loop will run 0..13, which is 14 iterations, not 13, just like your first loop runs 0..3, which is 4 iterations.
[Just because I made one mistake doesn't mean that everything else I said is wrong!]
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
awesome its all fixed up now, thanks for your help guys
Code:struct Card { int suit; int value; }; class Deck { public: Deck() { int x; int y; int z = 0; for (y = 0; y < 4; y++) { for (x = 0; x < 13; x++) { Cards[z].suit = y; Cards[z].value = x; z++; } } } //private: Card Cards[52]; };
Sometimes I forget what I am doing when I enter a room, actually, quite often.