Deck.h
#ifndef DECK_H
#define DECK_H
class Deck
{
public:
struct card{int symbol; int value;};
card card_list[52];
void generate_deck();
void main();
private:
static int const diamond = 1;
static int const club = 2;
static int const heart = 3;
static int const spade = 4;
};
#endif
Deck.cpp
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <time.h>
#include "Deck.h"
using namespace std;
void Deck::generate_deck()
{
for(int array_location=0;array_location<=12;array_location++)
{
card_list[array_location].symbol = diamond;
card_list[array_location].value = array_location+1;
}
}
void Deck::main()
{
generate_deck();
}
I get an access violation error when I try to compile and the compiler will just crash.
However, everything would work fine if I made the declaration for card card_list[52] inside the class instead of the header.
*Note : the code above is just a small part of the whole program.