Jump to content
  • Advertisement
Sign in to follow this  
Catkill

Arrays and classes

This topic is 3441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just a quick question - for my card game im trying to get it to display the Suit so i have: char* Suit[]= {"Hearts","Spades","Clubs","Diamonds"}; class Card { public: int Get_Value(int Random_Number) { Value = Deck[Random_Number]; return Value; } char Get_Suit(int Random_Number) { Suitptr = &Suit; Suit = Suit[Random_Number%4]; return Suitptr; } int Value; char *Suitptr, Suit; }; but its wrong ,so waht do i need to do to fix it ? yes im a beginner lol Cheers Catkill

Share this post


Link to post
Share on other sites
Advertisement
What is the purpose of those three member variables? Why don't you just return the right thing?

char* Get_Suit(int Random_Number)
{
return Suit[Random_Number % 4];
}

Notice the return type. It's a pointer to a char, not a single char.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!