I wanted to have an enum class with it's object declared in the header file of my program. I need to modify the state multiple times during the program but it doesn't allow me to. When I run the program it says that there was a multiple definition error regarding the enum class.
I changed the object into static and the program worked (static combinations state;), but in an attempt to assign the state to something else it didn't change the state. In another cpp file I tried modifying the state this way (state = combinations::HIGHCARD)
#ifndef POKER_H_
#define POKER_H_
enum class combinations {
HIGHCARD, ONEPAIR, TWOPAIRS, THREEOFAKIND, STRAIGHT,
FLUSH, FULLHOUSE, FOUROFAKIND, STRAIGHTFLUSH, ROYALEFLUSH
};
combinations state;
void shuffle(int[][13]);
void assign(const char *[], const char *[], int[][13], const char *[], const char *[]);
int deal(const char *[], const char *[], const char *[]);
void printHand(const char *[], const char *[]);
void printWinningMassege(const int, const int, combinations, combinations);
bool isRoyalFlush(const char *[], const char *[], const char *[]);
int isStraightFlush(const char *[], const char *[], const char *[]);
int isFourOfaKind(const char *[], const char *[]);
int isFullHouse(const char *[], const char *[]);
int isFlush(const char *[], const char *[], const char *[]);
int isStraight(const char *[], const char *[]);
int isThreeOfaKind(const char *[], const char *[]);
int isTwoPair(const char *[], const char *[]);
int isPair(const char *[], const char *[]);
int isHighCard(const char *[], const char *[], const char *[]);
#endif // !POKER_H
Severity Code Description Project File Line Suppression State
Error LNK2005 "enum combinations state" (?state@@3W4combinations@@A) already defined in Poker.obj PokerDeals C:\Users\BoB\source\repos\PokerDeals\main.obj 1