How can I access a struct (from a header file)?
Ok, I am loving C++ so far. I am creating a card program. Here is a snippet of my header file.
Code:
struct card
{int value; char suit;};
card c2={2,'c'}; card d2={2,'d'}; card s2={2,'s'}; card h2={2,'h'};
That is the line for 2 of clubs, diamonds, spades and hearts. I declared all 52 cards. =)
Now in my main program, I can not figure out how to declare a new (struct?) hand that has 2 cards in it.
What do I cin>>? an int? char[2]? string? struct?
Something like: If the user types c2 for their first card, then use the struct I called c2. (then I can write the following:)
Code:
if (firstcard.value==secondcard.value)
{cout<<"That is a pair of "<<firstcard.value<<"\'s";}
else
{cout<<"That is not a pair.";}
So how do I reference a struct (from a header file) based on user input?