So I realize this may have been answered in another posting (if so please link it to me so no one has to copy/paste the whole response), but I'm wondering if C++ allows for a class to have a function that calls the function of another class (that it is friends with) that in turn calls a function in a third class (again they are friends). To explain what I want I have a class called hand that has a function that calls a function called createCard in the class of Card, this in turn calls the function drawCard in the class of Deck. Anyone have an idea as to how to approach this?
Well, of course the various functions need to have access to a instance of the objects that its calling a function from (hopefully the same instance, as you don't want a new deck to be created each time). Other then that I don't see why you would have a problem with that.
ICE the problem with that idea is that Im using this for a blackjack game so Im just using a vector of ints for the deck pulling one of them out with a rand function then removing that storage passing the number to class card which then assigns it a rank a suit and a value (since all face cards have a value of 10). So I wanna call a function from the players hand that sends a request to the card class that in turn request an int from the deck that int gets passed to the card class which assigns its info then passes that to the appropiate hand. Im starting to think the only reliable way would be to use a few function calls directly call the deck from the hand get the int then pass it to card which would return the correct card.
So I wanna call a function from the players hand that sends a request to the card class that in turn request an int from the deck that int gets passed to the card class which assigns its info then passes that to the appropiate hand.
The hand shouldn't have to ask for a card. There should be a Dealer that takes a Card from the Deck and places it in a Hand.