Hi guys and girls,
I've decided to pick up C++ again after not using it for 2 nearly 3 years.
I've been programming in java and c# in the mean time so my understanding of programming is very good.
I've been trying to make a pack of cards but for some reason I can't understand the error im getting.
card header and class file:
#include <iostream>
using namespace std;
class Card
{
public:
enum Values{Ace,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,Jack,Queen,King};
enum Suits{Hearts,Clubs,Diamonds,Spades};
Card();
Card(Suits newSuit, Values newValue);
string returnSuit();
string returnValue();
string printCard();
char* suitString[4];
char* valueString[13];
private:
Values value;
Suits suit;
};
#include "Card.h"
#include <iostream>
using namespace std;
Card::Card(Suits newFace, Values newValue)
{
suit = newFace;
value = newValue;
}
string Card::returnSuit()
{
char* suitString[4] = {"Hearts", "Clubs", "Diamonds", "Spades"};
return suitString[suit];
}
string Card::returnValue()
{
char* valueString[13] = {"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};
return valueString[value];
}
string Card::printCard()
{
string temp = returnValue().append(" of ");
string tempo = returnSuit().c_str();
string final = temp.append(tempo).c_str();
return final;
}
Card::Card()
{
suit = Card::Suits::Hearts;
value = Card::Values::Ace;
}
This is working fine.
but when i add my deck class I suddely get an error
#include "Card.h"
using namespace std;
class Deck
{
public:
Deck();
Card cardAt(int pos);
Card *deck[52];
}
#include "Deck.h"
#include "Card.h"
using namespace std;
Deck::Deck()
{
int i = 0;
}
Now i know the constructor of Deck does nothing. But I can't get it to compile even with that code.
the error it throws when compiling is:
1>c:\visual studio\projects\blackjack\blackjack\card.h(2): error C2143: syntax error : missing ';' before 'using'
1>c:\visual studio\projects\blackjack\blackjack\card.h(5): error C2011: 'Card' : 'class' type redefinition
1> c:\visual studio\projects\blackjack\blackjack\card.h(5) : see declaration of 'Card'
If i comment out my Deck.cpp then it compiles.
Any help is much appreciated.