C++ enum pointers

  c++, class, conditional-statements, enums, pointers

I’ve got to setup a deck of cards,

Im using an enum to keep tract of the value of the cards (cards are words that will have meaning to a game)

My question is how could we use a pointer to a enum to check the value

This is the line I use to check:

if(card->getAffect() == Card::cardType::bomb)
Card::cardType Card::getAffect()
{
    return *face;
}
class Card
{
public:
    enum cardType {...};
private:
    cardType* face;
};

I get a segmentation fault when i call getAffect, but I dont understand why!

I’m also keeping the enum as a pointer as one of the requirements are:
All data members of user-defined class type must be of pointer type.

Source: Windows Questions C++

LEAVE A COMMENT