![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
Which is preferable?
I'm writing a program that uses playing cards. In my card class, I'm not hardcoding the fact that there are four suits and thirteen numbers in each, because I want it to be flexible to allow me to in the future create decks of non-standard cards, e.g. tarot cards.
So I have this: //suits: number of suits
//numbers: number of members of each suit
template<unsigned suits, unsigned numbers> class Card
{
/* ... */
}template<class card_type> class Deck
{
std::deque<card_type> card_container;
/* ... */
}template<unsigned suits, unsigned numbers> class Deck
{
std::deque<Card<suits,numbers>> card_container;
/* ... */
}Note: There may be syntax errors in this post as I'm just getting back into programming after a long absense. I hope, however, that you can understand my point. If you find any errors, please correct me.
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials. --WilliamSChips on Slashdot |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|