Thread: Trying to make a deck of cards.

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    36

    Trying to make a deck of cards.

    My deck has a private member variable with 52 values in it. I have another classes called card that has a rank, for Ace - King, and a suit for C/S/H/D and I'm trying to read this into the array but I do not know how to access the enumerated types of Rank and Suit though the for loop I provided. Any help?

    Code:
    cDeck::cDeck()
    {
    	int deckNumber = 0;
    	for ( int j = 0; j < 4; j++)
    	{
    		for( int i = 0; i < 13; i++)
    		{
    			m_deck[deckNumber].SetRank(cCard::Rank::[i]);
    			m_deck[deckNumber].SetSuit(cCard::Suit::Clubs);
    			deckNumber++;
    		}
    	}
    
    }

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Likely:
    Code:
    m_deck[deckNumber].SetRank(i);
    m_deck[deckNumber].SetSuit(j);
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 11-05-2009, 11:06 PM
  2. Shuffling a deck?
    By Neo1 in forum C++ Programming
    Replies: 23
    Last Post: 07-16-2007, 01:21 AM
  3. Deck Shuffle
    By pjharris in forum C++ Programming
    Replies: 51
    Last Post: 01-06-2006, 04:59 PM
  4. Problem with deck class.
    By SlyMaelstrom in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2005, 06:00 PM
  5. filling a deck of cards
    By lakai02 in forum C Programming
    Replies: 6
    Last Post: 12-07-2002, 10:13 AM