I get these errors each time I try to declare an instance of another object Hand
as a parameter of a method of another class on the same header and source files.
Even though the declaration and implementation statements are the same.
Errors:
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "Hand" is undefined Risk
C:\Users\ebrah\source\repos\Risk\Risk\Risk\Cards.h 44
Severity Code Description Project File Line Suppression State Error (active)
E0147 declaration is incompatible with "void Deck::draw(<error-type> &hand)"
(declared at line 44 of "C:\Users\ebrah\source\repos\Risk\Risk\Risk\Cards.h")
Risk C:\Users\ebrah\source\repos\Risk\Risk\Risk\Cards.cpp 186
My code:
In the header file:
class Card {
private:
static unsigned int nextCardID;
unsigned int cardID;
CardType cardType;
public:
Card();
~Card();
//Card(const Card &card);
Card(CardType armyType);
CardType getArmyType() const;
void setArmyType(CardType &armytype);
int getCardID() const;
void play(list<Card*> handCards, CardType& card);
friend ostream& operator<<(ostream& strm, const Card& card);
};
class Deck{
private:
list<Card> allCards;
list<Card*> deckCards;
void generateCard(int numberOfCounteries);
public:
Deck();
~Deck();
Deck(int numberOfCounteries);
void draw(Hand& hand);
friend ostream& operator<<(ostream& strm, const Deck& deck);
list<Card> getAllCards() const;
void setAllCards(list<Card> allCards);
list<Card*> getDeckCards() const;
void setDeckCards(list<Card*> deckCards);
};
class Hand {
private:
list<Card*> handCards;
public:
Hand();
~Hand();
friend ostream& operator<<(ostream& strm, const Hand hand);
list<Card*> getHandCards() const;
void setHandCards(list<Card*> handCards);
};
In the source file:
void Deck::draw(Hand& hand)
{
}
I also would like to know how to return a reference to a list
.
Thank you.