Hi. I'm at a complete loss I'm trying to make a deck of cards that can be shuffled and distributed to 4 players. I have to use the three classes and I have to code out the shuffle and search functions. I don't see why my sort function in the Player class isn't working. It relies on the overloaded "<" operator from the card class. Any suggestions would be nice.
#include "pch.h"
#include<iomanip>
#include<iostream>
#include<string>
using namespace std;
enum Suit { Club, Diamond, Heart, Spade };
class Card {
private:
Card dek[52];
Deck deck;
Player hand1[13];
Player hand2[13];
Card hand3[13];
Card hand4[13];
What is all this about?
Doesn't a Deck already have an array of cards?
Doesn't a Player already have an array of cards called hand?
cout << dek << endl;
What exactly are you trying to print here? Where is the overloaded operator<< for this to happen?
By the way you may want to consider creating overloads for each of your classes for the ostream operator<<, they may help you better understand what each class is doing?
Okay so then what is the problem? You have a Deck that contains a vector/array of cards, and a Player that has a vector/array of cards, take cards from a shuffled Deck and give them to the various players.
Also why does Player have a function named "Deal"? Isn't dealing part of the general game? Does it really belong to the Player or the Deck?
I really think you need to go back to the design phase and rethink the purposes of your classes. And remember in C++ not everything must be contained inside a class.
I have to use the three classes
Were the names and purposes supplied by the assignment or are all the details your responsibility?
Are you allowed to use some of the standard C++ features like std::vector, std::sort, std::shuffle, etc? Or are you required to "roll your own" versions of those functions/classes?
You'd be surprised how few of us have memorized the entire list of error code numbers from the specific compiler you happen to be using. Is it really too much effort to post the entire error message you're getting?
And, of course, post the code that's giving you that error. Properly formatted.