Generating a Deck of Cards

前端 未结 12 920
暖寄归人
暖寄归人 2020-12-09 06:20

I\'m trying to make a simple blackjack program. Sadly, I\'m having problems right off the bat with generating a deck of cards.

#include 
#inc         


        
12条回答
  •  不知归路
    2020-12-09 07:03

    As mentioned by others, you can use 'T' for ten, J, Q, and K for the figures. As far as push_back.. since deck is a vector of chars, you can pass only one char to push_back as argument. Passing both the card value (1...9, T, J, Q, K) and its suite doesn't work.

    I personally would create a little struct, to represent a Card, with a Value and a Suite property. Then, you can make your deck a vector of Cards .

    Edited: fixing last word since vector (less-than) Card (greater-than) was rendered as vector (nothing).

提交回复
热议问题