41
Coding / Re: Help:Pokemon type system[C++]
« on: July 18, 2006, 01:41:40 pm »
A class or structure would be the best type of way to do it.
Arrays would work, but you cannot store different types of data in them (though you may only need integers, then again you may need doubles for something, but structures make it easier to read).
Do you know how to set up a structure?
I think (god I'm out of the C++ loop) it's something like this:
You'd then create a "pocketMonster" like this:
And then set their details later by doing stuff like this:
Classes are more useful than structures because you can have functions in them (though in C++ you can in both, but you want to use a class anyway). But you only wanted data storage.
You should google a tutorial on Classes and Structure in C++.
Google is your friend.
Arrays would work, but you cannot store different types of data in them (though you may only need integers, then again you may need doubles for something, but structures make it easier to read).
Do you know how to set up a structure?
I think (god I'm out of the C++ loop) it's something like this:
Code: [Select]
struct pocketMonster{
char * nickName;
char pokemonType; //Only use a character if you're obnly gonna have a max of 255 pokemon
int attack;
int defense;
};
You'd then create a "pocketMonster" like this:
Code: [Select]
pocketMonster pikachu;
And then set their details later by doing stuff like this:
Code: [Select]
pikachu.attack = 10;
Classes are more useful than structures because you can have functions in them (though in C++ you can in both, but you want to use a class anyway). But you only wanted data storage.
You should google a tutorial on Classes and Structure in C++.
Google is your friend.