E
Eric C
I'm reading a c++ book by Eric Nagler named Learning C++ and I ran
into an exercise that requires a cpp file that defines several member
functions of a header. Here is my problem, it defines a constructor
that requires two enum types to be initialized. I haven't been able to
figure it out. Here is the code for the header:
--------------------
#define CARD_H
class Card {
public:
enum Suit {
Clubs, Diamonds, Hearts, Spades
};
enum Rank {
Ace, Deuce, Trey, Four, Five, Six, Seven,
Eight, Nine, Ten, Jack, Queen, King
};
Card(Suit, Rank);
Suit getSuit() const;
Rank getRank() const;
bool equals(Card const &) const;
private:
Suit const suit;
Rank const rank;
Card(Card const &);
};
#endif
--------------------
Now I've created a .cpp file to define these member functions,
including the constructor Card(Suit, Rank);. How do I define enum
types in this case? I'd really appreciate some help. Thanks
Eric
into an exercise that requires a cpp file that defines several member
functions of a header. Here is my problem, it defines a constructor
that requires two enum types to be initialized. I haven't been able to
figure it out. Here is the code for the header:
--------------------
#define CARD_H
class Card {
public:
enum Suit {
Clubs, Diamonds, Hearts, Spades
};
enum Rank {
Ace, Deuce, Trey, Four, Five, Six, Seven,
Eight, Nine, Ten, Jack, Queen, King
};
Card(Suit, Rank);
Suit getSuit() const;
Rank getRank() const;
bool equals(Card const &) const;
private:
Suit const suit;
Rank const rank;
Card(Card const &);
};
#endif
--------------------
Now I've created a .cpp file to define these member functions,
including the constructor Card(Suit, Rank);. How do I define enum
types in this case? I'd really appreciate some help. Thanks
Eric