I'm trying to write a program that sets up a nested structure and then initializes an array of that structure. It's giving me some weird errors. Here's all the relevant code:
//Structure called Stats for storing initial character stats
struct Stats{
string name;
int level;
int HP;
int STR;
int CON;
int DEX;
int INT;
int WIS;
int CHA;};
//Structure called Growth for storing character growth per level.
struct Growth{
int HPperlvl;
int STRperlvl;
int CONperlvl;
int DEXperlvl;
int INTperlvl;
int WISperlvl;
int CHAperlvl;};
struct Holdstats{
Stats classstats;
Growth classgrowth;};
const int SIZE = 10;
Holdstats classlist[SIZE];
Holdstats charlist[SIZE];
//Define initial classes, to be stored in the Classes structure
classlist[0].classstats = {"Fighter", 1, 18, 10, 10, 10, 10, 10, 10};
classlist[0].classgrowth = {1,1,1,1,1,1,1};
classlist[1].classstats = {"Wizard", 1, 10, 10, 10, 10, 10, 10};
classlist[1].classgrowth = {1,1,1,1,1,1,1}
My compiler thinks that when I type "classlist[0].classstats" that I'm trying to initialize an array of size 0. The way I read this I'm trying to access the first element of the classlist array. Is this written correctly?
It'd be great if someone could give me a short example of what such an array looks like. From there I'm thinking of writing it as a vector