The main thing wrong with what you have is that deal() expects an array of cards and you give it one card. The card you are giving it also happens to be out of range (an array of size 52 can only be accessed by 0-51).
Another thing is that you've named the struct "card", but try to make "Card". Classes/Structs should begin with capitals, variables with lowercase.
when you say
array[51]
you are talking about the value in the array at index 51. If you say
array
you are talking about the address of the array in memory, and you can pass the whole thing.
line 34 could be
Player.deal(deck);
, and that aught to work. Or change the index (to something less than 52) at line 34, and take out the [] in the function declaration/definition.
Edit: Also, when you pass the array the function has no idea what size the array is. As such:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
void player::deal(const Deck& deck[], const int SIZE)
{
// A loop
for (int i = 0; i < SIZE; i++)
{
cout << deck[i].card << endl;
}
}
//main
const int SIZE = 52;
Card deck[SIZE];
Player player;
player.deal(deck, SIZE);
| |
Of course, this doesn't initialize Card's variables to anything, so it's gonna be nonsense.