How do I get classes within a class???
For instance... I have the class Deck, which represents a deck of cards, and I want another class, derived from that, called cards, I want class Deck to have a class array called Cards[52], so I can assign all the different values and strings to the individual Cards class instances and have the class Deck do things to the deck as a whole... Im talkin something like this
class Deck{
protected:
class Cards[52]; // This doesnt work to have multiple instances in the class
public:
void Shuffle();
};
class Cards : public Deck{
Cards(int,string);
};
ik that you might not understand why i want to do this in two different classes, but i do... so please just gimme a clear cut answer. please and thank you!
Manutebecker
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 3
Don't define class Card within class Deck.
Create a card class.
Then let deck class contain an array of card objects
class Card {
string suit;
int value;
///more stuff
};
class Deck{
Card theDeck[52];
//more stuff
};
vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228