Best way to store a deck of cards? (Array, Vector or something else?)

I decided to make a Black Jack program to relearn programming/c++.

I've gotten as far as making to user choose amount of decks and generating the cards. Initially I stored the card info inside a string two-dimensional array like this:
string card[CARDS_IN_A_DECK*g_number_of_decks][4];
After reading a bit about it online and running into some problems I'm reconsidering.

I want to store following information about the card:
1
2
3
4
char card_suit = {"S", "H", "D", "C"};
string card_rank = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
int card_value = {2,3,4,5,6,7,8,9,10,10,10,10,0};
bool card_status = {0,1};


The variables will be defined in a subfunction in a separate file like this:

1
2
3
4
5
6
7
8
9
10
11
#include "launch_settings.h"
int launch_settings();
int create_deck(); // We don't know the dimension of the array we want returned from this function yet. Is that an issue?

int main()
{
	launch_settings(); // In this function, the user enters the amount of decks used, which means we'll know the amount of cards (size of array).
	create_deck(); // When calling this function, the size of the array we want returned from it will be known.

return 0;
}


So, the variables will be created in a subfunction, returned to main() and used as arguments to subfunctions. The variables will continuously be changed (the deck will get shuffled after a few hands and the boolean value will switch after each card has been played.
So, what is the best way to store this information?

* Inside a two-dimensional array. (Problematic since I have different types of variables; int, string, etc. Ive also read that arrays should not be returned from functions.)
* Inside multiple one dimensional arrays. (Doable, but return from function still might be an issue).
* A vector inside a vector. (Is it doable with different types?)
* Multiple vectors (one for each type of variable).
* Wrapper class. (is that too much for a beginner?)
* Should I use global variables? (They will be used in pretty much every function after all..)

Thanks in advance!
I'd go for the vector<structure/class> idea, where each element of the vector represents a individual card. Stay away from global variables whenever possible.

+1 to vector of structures.
Yeah, I read others suggesting the same things for similar applications. Guess I got it confirmed now.

Is either of you familiar with an example of this approach that might help me get started?
Thanks.
something like:
1
2
3
4
5
6
7
8
9
10
11
struct card
{
    char suite;
    char rank;
    bool status;
};

//...
//creating a vector of cards and plasing queen of spades into it
std::vector<card> deck;
deck.push_back({'S', 'Q', true});
I'd suggest creating a struct or class for your cards.
1
2
3
4
5
  struct card
  {  char suit;
      string rank;
      int value;
  };

Your deck or decks simply become a vector of cards.
1
2
 
  vector<card>  shoe;

If you're playing with 4 decks, push 52 cards onto the shoe 4 times, then shuffle.
Thanks for your help guys! My deck is now residing inside a struct!
Topic archived. No new replies allowed.