Create package of Structs

Hey all,
What is the best way to include a whole bunch of structs into a program. I'm messing around with a pokemon game and I need to have access to their stat data. Something like..

Struct Pikachu
int HP = 20;
int attack = 22;
int defense = 17;
int speed = 25;

I could write them all in my driver program, but that looks bad and clunky. If a class is the best way to go, do I need a header file and .cpp file if I only want to include structs?

~The poridgemaster
closed account (zb0S216C)
The best option is not to create a structure for each Pokemon, but to create a structure which contains all the data that each Pokemon has in common. For example:

struct Pokemon
    int HP;
    int Attack;
    int Defence;
    int SpAttack;
    int SpDefence;

Since each Pokemon has the above traits in common, we can easily avoid making the same data structure multiple times (if I remember rightly, there's ~260 Pokemon?). So when we want to create a new Pokemon, we just instantiate the data structure (creating a new Pokemon):

Pokemon Pikachu; // "Pikachu" is a "Pokemon" 

Then, to access "Pikachu"'s data, we use the member-access operator (.):

Pikachu.HP = ....;

[Note: I used to play a lot of Pokemon when I was a toddler]


Last edited on
Good call. Thank you. Now there are like over 500 pokemon I think. I only care about the first 150 for the most part, because the later gen ones are stupid.

Thanks again

~The poridgemaster
Topic archived. No new replies allowed.