Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ error error: hand was not declared in this scope; I'm very new in C++ and I've tried different ways of declaring 'hand' but I

C++ error error: hand was not declared in this scope;" I'm very new in C++ and I've tried different ways of declaring 'hand' but I keep getting the above error. Can you please tell me how to fix this small issue in main()? Code:

cards gen_deck_of_cards()

{

cards retval;

for (card_faces f(card_faces_begin), fEnd; f != fEnd; ++f)

for (card_suits s(card_suits_begin), sEnd; s != sEnd; ++s)

retval.push_back(card{*f,*s});

return retval;

}

//function that shuffles the deck of cards

void shuffle_cards(cards& cs)

{

std::random_device rd;

std::mt19937 gen(rd());

std::shuffle (cs.begin(), cs.end(), gen);

}

//function that draws 'N' cards from the deck

cards draw (std::size_t num, cards& deck)

{

auto pos = deck.begin();

if (num <= deck.size())

{

std::advance(pos, num);

}

pos = deck.end();

cards(deck.begin(), pos);

deck.erase(deck.begin(), pos);

return cards();

}

int main()

{

cards deck;

//generates a deck of cards

deck = gen_deck_of_cards();

//shuffles the deck of cards

shuffle_cards(deck);

//prints out the deck of cards

std::cout << "Deck: ";

copy(deck.begin(), deck.end(), std::ostream_iterator(std::cout," "));

std::cout << " " << "Drawing 3 cards... ";

//draws 3 cards from the deck

hand = draw(3,deck);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Discuss how selfesteem is developed.

Answered: 1 week ago

Question

4. What decision would you make and why?

Answered: 1 week ago

Question

3. Review the evidence. Do you believe the testimony presented?

Answered: 1 week ago

Question

1. What are the marketing implications of this situation?

Answered: 1 week ago