I am working on building a deck of Cards and have a Class Card consisting of an integer for the card value 2-14 (Ace is high) and a character for the suite S, C, D, and H.
class Card
{
public:
Card();
Card(char S, int V);
friend ostream& operator<<(ostream& out, const Card & t) {
out << t.value << " of " << t.suite << endl;
return out;
}
private:
char suite;
int value;
};
--------
I build the deck by adding one Card to the Deck array. the deck size is defined as 52 using #define Size 52
Array::Deck()
{
int value_opt[] = { 2,3,4,5,6,7,8,9,10,11,12,13,14 };
char suite_opt[] = { 'S', 'C', 'H', 'D' };
Card*deck = new Card[Size];
for (int i = 0; i < Size; i++) {
deck[i] = Card(suite_opt[count / 13], value_opt[count % 13]);
}
}
-------
if I print deck[i] I will get the memory allocation for the values in that index. how do I pull value for the char and the value for the int separately from deck[i]. and can I push that to my main line of code?