Copy and paste the code below. It is complete so remove what you have now (in card.h).
Code:
#ifndef CARD_H
#define CARD_H
#include <iostream>
#include <vector>
using namespace std;
class Card
{
public:
Card();
public:
// Observe the naughty space between > > !
typedef vector<pair<int,int> > VPairs;
VPairs Deck;
VPairs GetDeck()
{
return Deck;
}
private:
enum { Club, Spade, Diamond, Heart} suit;
};
Card::Card()
{
int cardtype;
for (int i = 0; i < 52; i++)
{
// First 13 cards are spades, next 13 are diamonds etc.
cardtype = i/13;
switch(cardtype)
{
case 0: suit = Club; break;
case 1: suit = Spade; break;
case 2: suit = Diamond; break;
case 3: suit = Heart; break;
}
Deck.push_back(pair<int, int>(suit, 2+i%13));
}
//Demonstration of how to iterate through a "vector" holding "pair" objects.
//It is only one more methods. See "void CardGames::Shuffle()" for the second
//way of iterating through the vector.
for(VPairs::iterator i = Deck.begin(); i != Deck.end(); ++i)
{
cout<< (*i).first <<" "<< (*i).second<<endl;
}
}
#endif //CARD_H