Im trying to make a class CardDeck with the constructor vector<Card> CardDeck
My Card class looks like this
Card.h file:
enum Suit{clubs = 0, diamonds, hearts, spades};
enum Rank{two = 2, three, four, five, six, seven, eight,
nine, ten, jack, queen, king, ace};
class Card{
private:
Suit s;
Rank r;
public:
Card(Suit suit, Rank rank)
:s{suit}, r{rank} {};
Suit getSuit() const;
Rank getRank() const;
string toString() const;
string toStringShort() const;
};
I now want to make a CardDeck class that will construct the vector
cards
inside CardDeck
CardDeck.h file:
#include "Card.h"
class CardDeck
{
private:
vector<Card> cards{}; //Where I'm stuck
public:
//...
};
Is there a way to loop through all Suits
and Ranks
like this
Pseudocode:
for s in Suits:
for r in Ranks:
cards.push_back(Card{s, r})