I have already re-modifed the program like this:
Code:
//deck.h
#ifndef deck_h
#define deck_h
#include <vector>
#include <cstdlib>
class Deck
{
public:
Deck() { card.reserve(52); } // default constructor, sets the initial size of 52
void shuffle(); // method of shuffle cards
Card operator[](int index) { return card[index]; } // Overload the [] operator so that a programmer
// can access each Card in the Deck using array notation.
private:
vector<int> card; // STL vector of type card.
};
#endif
Here is deck.cpp file
Code:
// deck.cpp
#include <cstdlib>
#include <iostream>
#include "deck.h"
void Deck::shuffle()
{
random_shuffle(card.begin(), card.end());
}
Deck& Card::operator[]( const Deck& playingCard )
In my header file, I have one overload operator []
Code:
Card operator[](int index) { return card[index]; } // Overload the [] operator so that a programmer
However, Do i need to implement it in my deck.cpp file?
If yes, can anyone suggest me how to code it?
Thanks.