Haven't worked with classes for a while, so please excuse all these dumb questions :P Still learning. Let me know if you need more info.

1>c:\users\adam\documents\visual studio 2010\projects\help\pusoy\pusoy\pusoy.cpp(24): error C3867: 'Deck::dealCard': function call missing argument list; use '&Deck::dealCard' to create a pointer to member

deck[] is a vector of Card (class)
I have a feeling that this is a bad way to do it anyways.

// Issue out the first card in the deck and then delete it from the deck
Card & Deck::dealCard()
	// Create temporary card
	Card temp = deck[0];
	// Delete top of deck
	return temp;

hand is a vector of Card

void Hand::addCard(Card & d)


int _tmain(int argc, _TCHAR* argv[])
	Deck testDeck;
	Card testCard;
	for (int i = 0; i < 52; i++)
		std::cout << testDeck.accessCard(i) << std::endl;
	for (int i = 0; i < 52; i++)
		std::cout << i << ") " << testDeck.accessCard(i) << std::endl;
	Hand testHand[4];
	for (int i = 0; i < 13; i++)
		testHand[0].addCard(testDeck.dealCard); // ERROR HERE
	return 0;

Edited 5 Years Ago by MasterGberry: n/a

Try this for Main line 13.


Edited 5 Years Ago by gerard4143: n/a

Your dealCard member function has a serious flaw: It returns a reference to a local variable, which will refer to nothing valid after the function has returned. You should probably just return a Card (assuming that Card is a class whose values you can copy).

If you're going to use a vector to represent your deck of cards, you should really take cards off the end, not the beginning. The reason is that every time you take a card off the beginning, the library has to copy all the rest of the cards.

Also, I note in passing that before you remove a card from a deck, you should really verify that the deck is not empty.

You can implement these three suggestions by changing the dealCard member as follows:

Card Deck::dealCard()
    // Create temporary card
    Card temp = deck.back();
    // Take the card out of the deck
    return temp;

Yeah, thats what i originally had, but the error message said something about an &. So i added one :S Ty fixed it

This question has already been answered. Start a new discussion instead.