I'm working on a school project and I've gotten stuck and I was hoping for some guidance. I've been writing testers for each of my files and things were going pretty well until I hit inheritance and now I can't use my vector functions even though I've included <vector>
There are several parts but this game has 3 header files (a Card, Pile, and Deck). The game is a version of War.
The Deck is supposed to publicly inherit all functions and members from the Pile class.
^push_back has red squiggles and is bringing up error "class Pile has no memeber "push_back". It goes away when I use vector<Card> gameDeck so it's got to be something with my Pile or how I've inherited it right?
Your << operator works with the contents of the variable named pile.
What's in pile? I see that your Deck constructor creates an object named gameDeck, populates it, and then throws it away. So what's meant to be in pile?
I messaged my professor and they cleared things up, my deck.cpp is supposed to be using deference this
1 2 3 4 5 6 7 8
Deck::Deck() {
for (int i = 1; i <= 13; i++) {
*this + Card(i, 'D');
*this + Card(i, 'S');
*this + Card(i, 'H');
*this + Card(i, 'C');
}
}
So I don't need to be making gameDeck in my .h file.
But in Pile is a vector of Cards, so I have a Card.h and Card.cpp files that make a card with rank and suit. Then use that to make a vector of Cards for my Pile which will be used to handle the opponents hands.
Thank you for the response Repeater, I should have this one figured out now. It was just that *this that I got stuck on.