card1.id = 1;
card1.val = 2;
card2.id = 2;
card2.val = 45;
So my question is firstly, is there a better way to implement this? (a vector of classes or something maybe?) and how can I call up a specific instance of the class. For example, if I want the val of a specific instance of the class, how best can I do that?
Your code fragment and question suggest you are a beginner? In that case, I would go for an array of objects.
(Remember to use code tags: the <> 'Format:' button to the right of this site's edit box will enter the required [code][/code] tags for you. Preferably, you'd go back and edit you original post to use tags?)
card cards; // an array of 52 cards
card.id = 1; // first card is at index 0, as usual for C arrays
card.val = 2;
cards.id = 2;
cards.val = 45;